diff --git a/tests/data/nomenclature_configs/multiple_repos_for_mapping.yaml b/tests/data/nomenclature_configs/multiple_repos_for_mapping.yaml new file mode 100644 index 00000000..ff2bd784 --- /dev/null +++ b/tests/data/nomenclature_configs/multiple_repos_for_mapping.yaml @@ -0,0 +1,9 @@ +repositories: + common-definitions: + url: https://github.com/IAMconsortium/common-definitions.git/ + legacy-definitions: + url: https://github.com/IAMconsortium/legacy-definitions.git/ +mappings: + repositories: + - common-definitions + - legacy-definitions diff --git a/tests/data/nomenclature_configs/multiple_repos_per_dimension.yaml b/tests/data/nomenclature_configs/multiple_repos_per_dimension.yaml new file mode 100644 index 00000000..6e510cd2 --- /dev/null +++ b/tests/data/nomenclature_configs/multiple_repos_per_dimension.yaml @@ -0,0 +1,10 @@ +repositories: + common-definitions: + url: https://github.com/IAMconsortium/common-definitions.git/ + legacy-definitions: + url: https://github.com/IAMconsortium/legacy-definitions.git/ +definitions: + variable: + repository: + - common-definitions + - legacy-definitions diff --git a/tests/data/nomenclature_configs/variable/.gitkeep b/tests/data/nomenclature_configs/variable/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_codelist.py b/tests/test_codelist.py index 4fd0a5c0..5668bc65 100644 --- a/tests/test_codelist.py +++ b/tests/test_codelist.py @@ -3,15 +3,16 @@ import pandas.testing as pdt import logging -from nomenclature.code import Code, RegionCode, MetaCode, VariableCode +from nomenclature.code import Code, RegionCode, MetaCode from nomenclature.codelist import ( CodeList, VariableCodeList, RegionCodeList, MetaCodeList, ) +from nomenclature.config import NomenclatureConfig -from conftest import TEST_DATA_DIR +from conftest import TEST_DATA_DIR, clean_up_external_repos def test_simple_codelist(): @@ -323,3 +324,18 @@ def test_MetaCodeList_from_directory(): } exp = MetaCodeList(name="Meta", mapping=mapping) assert obs == exp + + +def test_multiple_external_repos(): + nomenclature_config = NomenclatureConfig.from_file( + TEST_DATA_DIR / "nomenclature_configs" / "multiple_repos_per_dimension.yaml" + ) + try: + with raises(ValueError, match="Duplicate"): + variable_code_list = VariableCodeList.from_directory( + "variable", + TEST_DATA_DIR / "nomenclature_configs" / "variable", + nomenclature_config, + ) + finally: + clean_up_external_repos(nomenclature_config.repositories)