Skip to content

Commit

Permalink
Add tests for config
Browse files Browse the repository at this point in the history
  • Loading branch information
phackstock committed Jan 22, 2024
1 parent f30f37b commit 3f129f6
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path
from pytest import raises

from nomenclature.config import Repository, NomenclatureConfig
from nomenclature.config import Repository, NomenclatureConfig, CodeListConfig

from conftest import TEST_DATA_DIR
from conftest import TEST_DATA_DIR, clean_up_external_repos


def test_hash_and_release_raises():
Expand All @@ -25,3 +25,33 @@ def test_unknown_repo_raises():
NomenclatureConfig.from_file(
TEST_DATA_DIR / "nomenclature_configs" / "unknown_repo.yaml"
)


def test_multiple_definition_repos():
nomenclature_config = NomenclatureConfig.from_file(
TEST_DATA_DIR / "nomenclature_configs" / "multiple_repos_per_dimension.yaml"
)
try:
exp_repos = {"common-definitions", "legacy-definitions"}
assert nomenclature_config.repositories.keys() == exp_repos
assert nomenclature_config.definitions.variable.repositories == exp_repos
finally:
clean_up_external_repos(nomenclature_config.repositories)


def test_codelist_config_set_input():
exp_repos = {"repo1", "repo2"}
code_list_config = CodeListConfig(dimension="variable", repositories=exp_repos)
assert code_list_config.repositories == exp_repos


def test_multiple_mapping_repos():
nomenclature_config = NomenclatureConfig.from_file(
TEST_DATA_DIR / "nomenclature_configs" / "multiple_repos_for_mapping.yaml"
)
try:
exp_repos = {"common-definitions", "legacy-definitions"}
assert nomenclature_config.mappings.repositories == exp_repos
assert nomenclature_config.repositories.keys() == exp_repos
finally:
clean_up_external_repos(nomenclature_config.repositories)

0 comments on commit 3f129f6

Please sign in to comment.