From 86dd0785a0d3edde3e7b4018c38941018862593b Mon Sep 17 00:00:00 2001 From: Ivan Shcheklein Date: Sat, 11 Nov 2023 12:35:31 -0800 Subject: [PATCH] add tests for the index param keys --- tests/func/test_repo_index.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/func/test_repo_index.py b/tests/func/test_repo_index.py index fb5ce0702..9a0b06ea4 100644 --- a/tests/func/test_repo_index.py +++ b/tests/func/test_repo_index.py @@ -315,3 +315,26 @@ def test_ignored_dir_unignored_pattern(tmp_dir, dvc, scm): (stage,) = tmp_dir.dvc_gen({"data/raw/tracked.csv": "5,6,7,8"}) index = Index.from_repo(dvc) assert index.stages == [stage] + + +def test_param_keys_returns_default_file(tmp_dir, dvc): + tmp_dir.gen({"params.yaml": "param: 100\n"}) + index = Index.from_repo(dvc) + assert index.param_keys == {"repo": {("params.yaml",)}} + + +def test_param_keys_no_params(dvc): + index = Index.from_repo(dvc) + assert index.param_keys == {"repo": set()} + + +def test_param_keys_top_level_params(tmp_dir, dvc): + params_file_path = "classifier/custom_params_file.yaml" + top_level_params = f""" +params: + - {params_file_path} + """ + tmp_dir.gen(params_file_path, "param: 100\n") + tmp_dir.gen("dvc.yaml", top_level_params) + index = Index.from_repo(dvc) + assert index.param_keys == {"repo": {("classifier", "custom_params_file.yaml")}}