Skip to content

Commit

Permalink
Add test for multiple external repos
Browse files Browse the repository at this point in the history
  • Loading branch information
phackstock committed Jan 22, 2024
1 parent 3f129f6 commit 7402566
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/data/nomenclature_configs/multiple_repos_per_dimension.yaml
Original file line number Diff line number Diff line change
@@ -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
Empty file.
20 changes: 18 additions & 2 deletions tests/test_codelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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)

0 comments on commit 7402566

Please sign in to comment.