From 9314fef41229a8d5cd855ea3e3b5ad77a9dd83fd Mon Sep 17 00:00:00 2001 From: Philip Hackstock <20710924+phackstock@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:13:33 +0200 Subject: [PATCH] Clean up test data folders (#399) * Clean up test data folders * Make ruff * Rename IO folder to lowercase * Update tests --- tests/conftest.py | 8 +- .../{ => cli}/add-missing-variables/data.xlsx | Bin .../definitions/.gitkeep | 0 tests/data/{ => cli}/invalid_yaml/foo.yaml | 0 .../definitions/region/regions.yaml | 0 .../definitions/scenario/scenarios.yaml | 0 .../definitions/variable/variables.yaml | 0 .../mappings/mapping_1.yaml | 0 .../mappings/mapping_2.yaml | 0 .../definitions/empty}/.gitkeep | 0 .../definitions/region/regions.yaml | 0 .../definitions/variable/variables.yaml | 0 .../mappings/mapping_1.yaml | 0 .../mappings/mapping_2.yaml | 0 .../def/region/regions.yaml | 0 .../def/variable/variables.yaml | 0 .../non-default_folders/map/mapping_1.yaml | 0 .../non-default_folders/map/mapping_2.yaml | 0 .../definitions/region/regions.yaml | 0 .../definitions/variable/variables.yaml | 0 .../mappings/mapping_1.yaml | 0 .../mappings/mapping_2.yaml | 0 .../definitions}/region/regions.yaml | 0 .../definitions/variable/variables.yaml | 0 .../mappings/mapping_1.yaml | 0 .../mappings/mapping_2.yaml | 0 .../definitions/region/regions.yaml | 0 .../definitions/variable/variables.yaml | 0 .../variable/duplicate_entries.yaml | 0 .../duplicate_code_raises/bar.yaml | 0 .../duplicate_code_raises/foo.yaml | 0 .../duplicate_tag_raises/tag_1.yaml | 0 .../duplicate_tag_raises/tag_2.yaml | 0 .../definitions/scenario/scenarios.yaml | 0 .../variable/variables.yaml | 0 .../variable/variables.yaml | 0 .../unknown_weight/variable/variables.yaml | 0 .../general_filtering/basic_codelist.yaml | 0 .../definitions/scenario/scenarios.yaml | 0 .../meta/meta_indicators_allowed_values.yaml | 0 .../multiple_unit_codelist/variable.yaml | 0 .../region.yaml | 0 .../norway_as_bool/region.yaml | 0 .../region_codelist/simple/region.yaml | 0 .../region_filtering.yaml | 0 .../{ => codelist}/simple_codelist/foo.yaml | 0 .../definitions}/variable/tag_fuel.yaml | 0 .../definitions/variable/variables.yaml | 0 .../{ => codelist}/tagged_codelist/foo.yaml | 0 .../tagged_codelist/foo_attr_list.yaml | 0 .../tagged_codelist/tag_sector.yaml | 0 .../tagged_codelist/tag_source.yaml | 0 .../tagged_codelist/tag_species.yaml | 0 .../variable_complex_attr.yaml | 0 .../dimensions.yaml | 0 .../nomenclature.yaml | 0 .../nomenclature.yaml | 0 .../nomenclature.yaml | 0 .../general-config-only/nomenclature.yaml | 0 .../definitions/region/regions.yaml | 0 .../general-config/nomenclature.yaml | 0 .../hash_and_release.yaml | 0 .../multiple_repos_for_mapping.yaml | 0 .../multiple_repos_per_dimension.yaml | 0 .../unknown_repo.yaml | 0 .../empty => config/variable}/.gitkeep | 0 .../custom_dimension_nc}/region/regions.yaml | 0 .../scenario/scenarios.yaml | 0 .../variable/tag_fuel.yaml | 0 .../variable/variables.yaml | 0 .../extras_nc}/region/regions.yaml | 0 .../extras_nc/variable/variables.yaml | 0 .../validation_nc/region/regions.yaml | 0 .../validation_nc/variable/tag_fuel.yaml | 0 .../validation_nc/variable/variables.yaml | 0 .../data/{ => io}/excel_io/validation_nc.xlsx | Bin .../excel_io/validation_nc_duplicates.xlsx | Bin .../{ => io}/excel_io/validation_nc_flat.yaml | 0 .../excel_io/validation_nc_list_arg.xlsx | Bin .../excel_io/validation_nc_list_arg.yaml | 0 .../meta/meta_indicators_allowed_values.yaml | 0 .../meta/meta_indicators_test_data.yaml | 0 .../meta/meta_indicators_more_data.yaml | 0 .../excel_mapping_reference.yaml | 0 .../excel_model_registration.xlsx | Bin .../illegal_mapping_conflict_regions.yaml | 0 .../illegal_mapping_duplicate_common.yaml | 0 .../illegal_mapping_illegal_attribute.yaml | 0 .../illegal_mapping_invalid_format_dict.yaml | 0 .../illegal_mapping_model_only.yaml | 0 .../illegal_mapping_native_duplicate_key.yaml | 0 ...al_mapping_native_rename_key_conflict.yaml | 0 ...pping_native_rename_target_conflict_1.yaml | 0 ...pping_native_rename_target_conflict_2.yaml | 0 .../region_aggregation/working_mapping.yaml | 0 .../regionprocessor_duplicate/mapping_1.yaml | 0 .../regionprocessor_duplicate/mapping_2.yaml | 0 .../exclude_common_overlap.yaml | 0 .../exclude_native_overlap.yaml | 0 .../mapping_1.yaml | 0 .../mapping_2.yaml | 0 .../model_a.yaml | 0 .../regionprocessor_working/mapping_1.yml | 0 .../regionprocessor_working/mapping_2.yaml | 0 tests/test_cli.py | 63 +++++++++++----- tests/test_codelist.py | 69 +++++++++++------- tests/test_config.py | 20 ++--- tests/test_definition.py | 22 +++--- tests/test_definition_variable.py | 2 +- tests/test_meta.py | 16 ++-- tests/test_model_registration_parser.py | 12 ++- tests/test_region_aggregation.py | 62 +++++++++------- tests/test_testing.py | 6 +- tests/test_validation.py | 17 +++-- 114 files changed, 179 insertions(+), 118 deletions(-) rename tests/data/{ => cli}/add-missing-variables/data.xlsx (100%) rename tests/data/{ => cli}/empty_definitions_dir/definitions/.gitkeep (100%) rename tests/data/{ => cli}/invalid_yaml/foo.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions/definitions/region/regions.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions/definitions/scenario/scenarios.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions/definitions/variable/variables.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions/mappings/mapping_1.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions/mappings/mapping_2.yaml (100%) rename tests/data/{nomenclature_configs/variable => cli/non-default_dimensions_one_empty/definitions/empty}/.gitkeep (100%) rename tests/data/{ => cli}/non-default_dimensions_one_empty/definitions/region/regions.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions_one_empty/definitions/variable/variables.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions_one_empty/mappings/mapping_1.yaml (100%) rename tests/data/{ => cli}/non-default_dimensions_one_empty/mappings/mapping_2.yaml (100%) rename tests/data/{ => cli}/non-default_folders/def/region/regions.yaml (100%) rename tests/data/{ => cli}/non-default_folders/def/variable/variables.yaml (100%) rename tests/data/{ => cli}/non-default_folders/map/mapping_1.yaml (100%) rename tests/data/{ => cli}/non-default_folders/map/mapping_2.yaml (100%) rename tests/data/{ => cli}/structure_validation/definitions/region/regions.yaml (100%) rename tests/data/{ => cli}/structure_validation/definitions/variable/variables.yaml (100%) rename tests/data/{ => cli}/structure_validation/mappings/mapping_1.yaml (100%) rename tests/data/{ => cli}/structure_validation/mappings/mapping_2.yaml (100%) rename tests/data/{custom_dimension_nc => cli/structure_validation_fails/definitions}/region/regions.yaml (100%) rename tests/data/{ => cli}/structure_validation_fails/definitions/variable/variables.yaml (100%) rename tests/data/{ => cli}/structure_validation_fails/mappings/mapping_1.yaml (100%) rename tests/data/{ => cli}/structure_validation_fails/mappings/mapping_2.yaml (100%) rename tests/data/{ => cli}/structure_validation_no_mappings/definitions/region/regions.yaml (100%) rename tests/data/{ => cli}/structure_validation_no_mappings/definitions/variable/variables.yaml (100%) rename tests/data/{ => codelist}/duplicate-code-list/variable/duplicate_entries.yaml (100%) rename tests/data/{ => codelist}/duplicate_code_raises/bar.yaml (100%) rename tests/data/{ => codelist}/duplicate_code_raises/foo.yaml (100%) rename tests/data/{ => codelist}/duplicate_tag_raises/tag_1.yaml (100%) rename tests/data/{ => codelist}/duplicate_tag_raises/tag_2.yaml (100%) rename tests/data/{ => codelist}/end_whitespace/definitions/scenario/scenarios.yaml (100%) rename tests/data/{ => codelist}/failing_variable_codelist/rename_arg_conflict/variable/variables.yaml (100%) rename tests/data/{ => codelist}/failing_variable_codelist/rename_undefined_target/variable/variables.yaml (100%) rename tests/data/{ => codelist}/failing_variable_codelist/unknown_weight/variable/variables.yaml (100%) rename tests/data/{ => codelist}/general_filtering/basic_codelist.yaml (100%) rename tests/data/{ => codelist}/hidden_character/definitions/scenario/scenarios.yaml (100%) rename tests/data/{ => codelist}/meta/meta_indicators_allowed_values.yaml (100%) rename tests/data/{ => codelist}/multiple_unit_codelist/variable.yaml (100%) rename tests/data/{ => codelist}/region_codelist/countries_attribute_non-existing_name/region.yaml (100%) rename tests/data/{ => codelist}/region_codelist/norway_as_bool/region.yaml (100%) rename tests/data/{ => codelist}/region_codelist/simple/region.yaml (100%) rename tests/data/{ => codelist}/region_to_filter_codelist/region_filtering.yaml (100%) rename tests/data/{ => codelist}/simple_codelist/foo.yaml (100%) rename tests/data/{custom_dimension_nc => codelist/stray_tag/definitions}/variable/tag_fuel.yaml (100%) rename tests/data/{ => codelist}/stray_tag/definitions/variable/variables.yaml (100%) rename tests/data/{ => codelist}/tagged_codelist/foo.yaml (100%) rename tests/data/{ => codelist}/tagged_codelist/foo_attr_list.yaml (100%) rename tests/data/{ => codelist}/tagged_codelist/tag_sector.yaml (100%) rename tests/data/{ => codelist}/tagged_codelist/tag_source.yaml (100%) rename tests/data/{ => codelist}/tagged_codelist/tag_species.yaml (100%) rename tests/data/{ => codelist}/variable_codelist_complex_attr/variable_complex_attr.yaml (100%) rename tests/data/{nomenclature_configs => config}/dimensions.yaml (100%) rename tests/data/{ => config}/double_stacked_external_repo/nomenclature.yaml (100%) rename tests/data/{ => config}/general-config-only-country/nomenclature.yaml (100%) rename tests/data/{ => config}/general-config-only-nuts/nomenclature.yaml (100%) rename tests/data/{ => config}/general-config-only/nomenclature.yaml (100%) rename tests/data/{ => config}/general-config/definitions/region/regions.yaml (100%) rename tests/data/{ => config}/general-config/nomenclature.yaml (100%) rename tests/data/{nomenclature_configs => config}/hash_and_release.yaml (100%) rename tests/data/{nomenclature_configs => config}/multiple_repos_for_mapping.yaml (100%) rename tests/data/{nomenclature_configs => config}/multiple_repos_per_dimension.yaml (100%) rename tests/data/{nomenclature_configs => config}/unknown_repo.yaml (100%) rename tests/data/{non-default_dimensions_one_empty/definitions/empty => config/variable}/.gitkeep (100%) rename tests/data/{extras_nc => data_structure_definition/custom_dimension_nc}/region/regions.yaml (100%) rename tests/data/{ => data_structure_definition}/custom_dimension_nc/scenario/scenarios.yaml (100%) rename tests/data/{stray_tag/definitions => data_structure_definition/custom_dimension_nc}/variable/tag_fuel.yaml (100%) rename tests/data/{ => data_structure_definition}/custom_dimension_nc/variable/variables.yaml (100%) rename tests/data/{structure_validation_fails/definitions => data_structure_definition/extras_nc}/region/regions.yaml (100%) rename tests/data/{ => data_structure_definition}/extras_nc/variable/variables.yaml (100%) rename tests/data/{ => data_structure_definition}/validation_nc/region/regions.yaml (100%) rename tests/data/{ => data_structure_definition}/validation_nc/variable/tag_fuel.yaml (100%) rename tests/data/{ => data_structure_definition}/validation_nc/variable/variables.yaml (100%) rename tests/data/{ => io}/excel_io/validation_nc.xlsx (100%) rename tests/data/{ => io}/excel_io/validation_nc_duplicates.xlsx (100%) rename tests/data/{ => io}/excel_io/validation_nc_flat.yaml (100%) rename tests/data/{ => io}/excel_io/validation_nc_list_arg.xlsx (100%) rename tests/data/{ => io}/excel_io/validation_nc_list_arg.yaml (100%) rename tests/data/{ => meta_validator}/definitions1/meta/meta_indicators_allowed_values.yaml (100%) rename tests/data/{ => meta_validator}/definitions2/meta/meta_indicators_test_data.yaml (100%) rename tests/data/{ => meta_validator}/definitions3/meta/meta_indicators_more_data.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/excel_mapping_reference.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/excel_model_registration.xlsx (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_conflict_regions.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_duplicate_common.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_illegal_attribute.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_invalid_format_dict.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_model_only.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_native_duplicate_key.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_native_rename_key_conflict.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_native_rename_target_conflict_1.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/illegal_mapping_native_rename_target_conflict_2.yaml (100%) rename tests/data/{ => region_processing}/region_aggregation/working_mapping.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_duplicate/mapping_1.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_duplicate/mapping_2.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_exclude_region_overlap/exclude_common_overlap.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_exclude_region_overlap/exclude_native_overlap.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_not_defined/mapping_1.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_not_defined/mapping_2.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_unexpected_region/model_a.yaml (100%) rename tests/data/{ => region_processing}/regionprocessor_working/mapping_1.yml (100%) rename tests/data/{ => region_processing}/regionprocessor_working/mapping_2.yaml (100%) diff --git a/tests/conftest.py b/tests/conftest.py index 156a4401..9f152fc0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,12 +26,16 @@ @pytest.fixture(scope="session") def simple_definition(): - yield DataStructureDefinition(TEST_DATA_DIR / "validation_nc") + yield DataStructureDefinition( + TEST_DATA_DIR / "data_structure_definition" / "validation_nc" + ) @pytest.fixture(scope="session") def extras_definition(): - yield DataStructureDefinition(TEST_DATA_DIR / "extras_nc") + yield DataStructureDefinition( + TEST_DATA_DIR / "data_structure_definition" / "extras_nc" + ) @pytest.fixture(scope="function") diff --git a/tests/data/add-missing-variables/data.xlsx b/tests/data/cli/add-missing-variables/data.xlsx similarity index 100% rename from tests/data/add-missing-variables/data.xlsx rename to tests/data/cli/add-missing-variables/data.xlsx diff --git a/tests/data/empty_definitions_dir/definitions/.gitkeep b/tests/data/cli/empty_definitions_dir/definitions/.gitkeep similarity index 100% rename from tests/data/empty_definitions_dir/definitions/.gitkeep rename to tests/data/cli/empty_definitions_dir/definitions/.gitkeep diff --git a/tests/data/invalid_yaml/foo.yaml b/tests/data/cli/invalid_yaml/foo.yaml similarity index 100% rename from tests/data/invalid_yaml/foo.yaml rename to tests/data/cli/invalid_yaml/foo.yaml diff --git a/tests/data/non-default_dimensions/definitions/region/regions.yaml b/tests/data/cli/non-default_dimensions/definitions/region/regions.yaml similarity index 100% rename from tests/data/non-default_dimensions/definitions/region/regions.yaml rename to tests/data/cli/non-default_dimensions/definitions/region/regions.yaml diff --git a/tests/data/non-default_dimensions/definitions/scenario/scenarios.yaml b/tests/data/cli/non-default_dimensions/definitions/scenario/scenarios.yaml similarity index 100% rename from tests/data/non-default_dimensions/definitions/scenario/scenarios.yaml rename to tests/data/cli/non-default_dimensions/definitions/scenario/scenarios.yaml diff --git a/tests/data/non-default_dimensions/definitions/variable/variables.yaml b/tests/data/cli/non-default_dimensions/definitions/variable/variables.yaml similarity index 100% rename from tests/data/non-default_dimensions/definitions/variable/variables.yaml rename to tests/data/cli/non-default_dimensions/definitions/variable/variables.yaml diff --git a/tests/data/non-default_dimensions/mappings/mapping_1.yaml b/tests/data/cli/non-default_dimensions/mappings/mapping_1.yaml similarity index 100% rename from tests/data/non-default_dimensions/mappings/mapping_1.yaml rename to tests/data/cli/non-default_dimensions/mappings/mapping_1.yaml diff --git a/tests/data/non-default_dimensions/mappings/mapping_2.yaml b/tests/data/cli/non-default_dimensions/mappings/mapping_2.yaml similarity index 100% rename from tests/data/non-default_dimensions/mappings/mapping_2.yaml rename to tests/data/cli/non-default_dimensions/mappings/mapping_2.yaml diff --git a/tests/data/nomenclature_configs/variable/.gitkeep b/tests/data/cli/non-default_dimensions_one_empty/definitions/empty/.gitkeep similarity index 100% rename from tests/data/nomenclature_configs/variable/.gitkeep rename to tests/data/cli/non-default_dimensions_one_empty/definitions/empty/.gitkeep diff --git a/tests/data/non-default_dimensions_one_empty/definitions/region/regions.yaml b/tests/data/cli/non-default_dimensions_one_empty/definitions/region/regions.yaml similarity index 100% rename from tests/data/non-default_dimensions_one_empty/definitions/region/regions.yaml rename to tests/data/cli/non-default_dimensions_one_empty/definitions/region/regions.yaml diff --git a/tests/data/non-default_dimensions_one_empty/definitions/variable/variables.yaml b/tests/data/cli/non-default_dimensions_one_empty/definitions/variable/variables.yaml similarity index 100% rename from tests/data/non-default_dimensions_one_empty/definitions/variable/variables.yaml rename to tests/data/cli/non-default_dimensions_one_empty/definitions/variable/variables.yaml diff --git a/tests/data/non-default_dimensions_one_empty/mappings/mapping_1.yaml b/tests/data/cli/non-default_dimensions_one_empty/mappings/mapping_1.yaml similarity index 100% rename from tests/data/non-default_dimensions_one_empty/mappings/mapping_1.yaml rename to tests/data/cli/non-default_dimensions_one_empty/mappings/mapping_1.yaml diff --git a/tests/data/non-default_dimensions_one_empty/mappings/mapping_2.yaml b/tests/data/cli/non-default_dimensions_one_empty/mappings/mapping_2.yaml similarity index 100% rename from tests/data/non-default_dimensions_one_empty/mappings/mapping_2.yaml rename to tests/data/cli/non-default_dimensions_one_empty/mappings/mapping_2.yaml diff --git a/tests/data/non-default_folders/def/region/regions.yaml b/tests/data/cli/non-default_folders/def/region/regions.yaml similarity index 100% rename from tests/data/non-default_folders/def/region/regions.yaml rename to tests/data/cli/non-default_folders/def/region/regions.yaml diff --git a/tests/data/non-default_folders/def/variable/variables.yaml b/tests/data/cli/non-default_folders/def/variable/variables.yaml similarity index 100% rename from tests/data/non-default_folders/def/variable/variables.yaml rename to tests/data/cli/non-default_folders/def/variable/variables.yaml diff --git a/tests/data/non-default_folders/map/mapping_1.yaml b/tests/data/cli/non-default_folders/map/mapping_1.yaml similarity index 100% rename from tests/data/non-default_folders/map/mapping_1.yaml rename to tests/data/cli/non-default_folders/map/mapping_1.yaml diff --git a/tests/data/non-default_folders/map/mapping_2.yaml b/tests/data/cli/non-default_folders/map/mapping_2.yaml similarity index 100% rename from tests/data/non-default_folders/map/mapping_2.yaml rename to tests/data/cli/non-default_folders/map/mapping_2.yaml diff --git a/tests/data/structure_validation/definitions/region/regions.yaml b/tests/data/cli/structure_validation/definitions/region/regions.yaml similarity index 100% rename from tests/data/structure_validation/definitions/region/regions.yaml rename to tests/data/cli/structure_validation/definitions/region/regions.yaml diff --git a/tests/data/structure_validation/definitions/variable/variables.yaml b/tests/data/cli/structure_validation/definitions/variable/variables.yaml similarity index 100% rename from tests/data/structure_validation/definitions/variable/variables.yaml rename to tests/data/cli/structure_validation/definitions/variable/variables.yaml diff --git a/tests/data/structure_validation/mappings/mapping_1.yaml b/tests/data/cli/structure_validation/mappings/mapping_1.yaml similarity index 100% rename from tests/data/structure_validation/mappings/mapping_1.yaml rename to tests/data/cli/structure_validation/mappings/mapping_1.yaml diff --git a/tests/data/structure_validation/mappings/mapping_2.yaml b/tests/data/cli/structure_validation/mappings/mapping_2.yaml similarity index 100% rename from tests/data/structure_validation/mappings/mapping_2.yaml rename to tests/data/cli/structure_validation/mappings/mapping_2.yaml diff --git a/tests/data/custom_dimension_nc/region/regions.yaml b/tests/data/cli/structure_validation_fails/definitions/region/regions.yaml similarity index 100% rename from tests/data/custom_dimension_nc/region/regions.yaml rename to tests/data/cli/structure_validation_fails/definitions/region/regions.yaml diff --git a/tests/data/structure_validation_fails/definitions/variable/variables.yaml b/tests/data/cli/structure_validation_fails/definitions/variable/variables.yaml similarity index 100% rename from tests/data/structure_validation_fails/definitions/variable/variables.yaml rename to tests/data/cli/structure_validation_fails/definitions/variable/variables.yaml diff --git a/tests/data/structure_validation_fails/mappings/mapping_1.yaml b/tests/data/cli/structure_validation_fails/mappings/mapping_1.yaml similarity index 100% rename from tests/data/structure_validation_fails/mappings/mapping_1.yaml rename to tests/data/cli/structure_validation_fails/mappings/mapping_1.yaml diff --git a/tests/data/structure_validation_fails/mappings/mapping_2.yaml b/tests/data/cli/structure_validation_fails/mappings/mapping_2.yaml similarity index 100% rename from tests/data/structure_validation_fails/mappings/mapping_2.yaml rename to tests/data/cli/structure_validation_fails/mappings/mapping_2.yaml diff --git a/tests/data/structure_validation_no_mappings/definitions/region/regions.yaml b/tests/data/cli/structure_validation_no_mappings/definitions/region/regions.yaml similarity index 100% rename from tests/data/structure_validation_no_mappings/definitions/region/regions.yaml rename to tests/data/cli/structure_validation_no_mappings/definitions/region/regions.yaml diff --git a/tests/data/structure_validation_no_mappings/definitions/variable/variables.yaml b/tests/data/cli/structure_validation_no_mappings/definitions/variable/variables.yaml similarity index 100% rename from tests/data/structure_validation_no_mappings/definitions/variable/variables.yaml rename to tests/data/cli/structure_validation_no_mappings/definitions/variable/variables.yaml diff --git a/tests/data/duplicate-code-list/variable/duplicate_entries.yaml b/tests/data/codelist/duplicate-code-list/variable/duplicate_entries.yaml similarity index 100% rename from tests/data/duplicate-code-list/variable/duplicate_entries.yaml rename to tests/data/codelist/duplicate-code-list/variable/duplicate_entries.yaml diff --git a/tests/data/duplicate_code_raises/bar.yaml b/tests/data/codelist/duplicate_code_raises/bar.yaml similarity index 100% rename from tests/data/duplicate_code_raises/bar.yaml rename to tests/data/codelist/duplicate_code_raises/bar.yaml diff --git a/tests/data/duplicate_code_raises/foo.yaml b/tests/data/codelist/duplicate_code_raises/foo.yaml similarity index 100% rename from tests/data/duplicate_code_raises/foo.yaml rename to tests/data/codelist/duplicate_code_raises/foo.yaml diff --git a/tests/data/duplicate_tag_raises/tag_1.yaml b/tests/data/codelist/duplicate_tag_raises/tag_1.yaml similarity index 100% rename from tests/data/duplicate_tag_raises/tag_1.yaml rename to tests/data/codelist/duplicate_tag_raises/tag_1.yaml diff --git a/tests/data/duplicate_tag_raises/tag_2.yaml b/tests/data/codelist/duplicate_tag_raises/tag_2.yaml similarity index 100% rename from tests/data/duplicate_tag_raises/tag_2.yaml rename to tests/data/codelist/duplicate_tag_raises/tag_2.yaml diff --git a/tests/data/end_whitespace/definitions/scenario/scenarios.yaml b/tests/data/codelist/end_whitespace/definitions/scenario/scenarios.yaml similarity index 100% rename from tests/data/end_whitespace/definitions/scenario/scenarios.yaml rename to tests/data/codelist/end_whitespace/definitions/scenario/scenarios.yaml diff --git a/tests/data/failing_variable_codelist/rename_arg_conflict/variable/variables.yaml b/tests/data/codelist/failing_variable_codelist/rename_arg_conflict/variable/variables.yaml similarity index 100% rename from tests/data/failing_variable_codelist/rename_arg_conflict/variable/variables.yaml rename to tests/data/codelist/failing_variable_codelist/rename_arg_conflict/variable/variables.yaml diff --git a/tests/data/failing_variable_codelist/rename_undefined_target/variable/variables.yaml b/tests/data/codelist/failing_variable_codelist/rename_undefined_target/variable/variables.yaml similarity index 100% rename from tests/data/failing_variable_codelist/rename_undefined_target/variable/variables.yaml rename to tests/data/codelist/failing_variable_codelist/rename_undefined_target/variable/variables.yaml diff --git a/tests/data/failing_variable_codelist/unknown_weight/variable/variables.yaml b/tests/data/codelist/failing_variable_codelist/unknown_weight/variable/variables.yaml similarity index 100% rename from tests/data/failing_variable_codelist/unknown_weight/variable/variables.yaml rename to tests/data/codelist/failing_variable_codelist/unknown_weight/variable/variables.yaml diff --git a/tests/data/general_filtering/basic_codelist.yaml b/tests/data/codelist/general_filtering/basic_codelist.yaml similarity index 100% rename from tests/data/general_filtering/basic_codelist.yaml rename to tests/data/codelist/general_filtering/basic_codelist.yaml diff --git a/tests/data/hidden_character/definitions/scenario/scenarios.yaml b/tests/data/codelist/hidden_character/definitions/scenario/scenarios.yaml similarity index 100% rename from tests/data/hidden_character/definitions/scenario/scenarios.yaml rename to tests/data/codelist/hidden_character/definitions/scenario/scenarios.yaml diff --git a/tests/data/meta/meta_indicators_allowed_values.yaml b/tests/data/codelist/meta/meta_indicators_allowed_values.yaml similarity index 100% rename from tests/data/meta/meta_indicators_allowed_values.yaml rename to tests/data/codelist/meta/meta_indicators_allowed_values.yaml diff --git a/tests/data/multiple_unit_codelist/variable.yaml b/tests/data/codelist/multiple_unit_codelist/variable.yaml similarity index 100% rename from tests/data/multiple_unit_codelist/variable.yaml rename to tests/data/codelist/multiple_unit_codelist/variable.yaml diff --git a/tests/data/region_codelist/countries_attribute_non-existing_name/region.yaml b/tests/data/codelist/region_codelist/countries_attribute_non-existing_name/region.yaml similarity index 100% rename from tests/data/region_codelist/countries_attribute_non-existing_name/region.yaml rename to tests/data/codelist/region_codelist/countries_attribute_non-existing_name/region.yaml diff --git a/tests/data/region_codelist/norway_as_bool/region.yaml b/tests/data/codelist/region_codelist/norway_as_bool/region.yaml similarity index 100% rename from tests/data/region_codelist/norway_as_bool/region.yaml rename to tests/data/codelist/region_codelist/norway_as_bool/region.yaml diff --git a/tests/data/region_codelist/simple/region.yaml b/tests/data/codelist/region_codelist/simple/region.yaml similarity index 100% rename from tests/data/region_codelist/simple/region.yaml rename to tests/data/codelist/region_codelist/simple/region.yaml diff --git a/tests/data/region_to_filter_codelist/region_filtering.yaml b/tests/data/codelist/region_to_filter_codelist/region_filtering.yaml similarity index 100% rename from tests/data/region_to_filter_codelist/region_filtering.yaml rename to tests/data/codelist/region_to_filter_codelist/region_filtering.yaml diff --git a/tests/data/simple_codelist/foo.yaml b/tests/data/codelist/simple_codelist/foo.yaml similarity index 100% rename from tests/data/simple_codelist/foo.yaml rename to tests/data/codelist/simple_codelist/foo.yaml diff --git a/tests/data/custom_dimension_nc/variable/tag_fuel.yaml b/tests/data/codelist/stray_tag/definitions/variable/tag_fuel.yaml similarity index 100% rename from tests/data/custom_dimension_nc/variable/tag_fuel.yaml rename to tests/data/codelist/stray_tag/definitions/variable/tag_fuel.yaml diff --git a/tests/data/stray_tag/definitions/variable/variables.yaml b/tests/data/codelist/stray_tag/definitions/variable/variables.yaml similarity index 100% rename from tests/data/stray_tag/definitions/variable/variables.yaml rename to tests/data/codelist/stray_tag/definitions/variable/variables.yaml diff --git a/tests/data/tagged_codelist/foo.yaml b/tests/data/codelist/tagged_codelist/foo.yaml similarity index 100% rename from tests/data/tagged_codelist/foo.yaml rename to tests/data/codelist/tagged_codelist/foo.yaml diff --git a/tests/data/tagged_codelist/foo_attr_list.yaml b/tests/data/codelist/tagged_codelist/foo_attr_list.yaml similarity index 100% rename from tests/data/tagged_codelist/foo_attr_list.yaml rename to tests/data/codelist/tagged_codelist/foo_attr_list.yaml diff --git a/tests/data/tagged_codelist/tag_sector.yaml b/tests/data/codelist/tagged_codelist/tag_sector.yaml similarity index 100% rename from tests/data/tagged_codelist/tag_sector.yaml rename to tests/data/codelist/tagged_codelist/tag_sector.yaml diff --git a/tests/data/tagged_codelist/tag_source.yaml b/tests/data/codelist/tagged_codelist/tag_source.yaml similarity index 100% rename from tests/data/tagged_codelist/tag_source.yaml rename to tests/data/codelist/tagged_codelist/tag_source.yaml diff --git a/tests/data/tagged_codelist/tag_species.yaml b/tests/data/codelist/tagged_codelist/tag_species.yaml similarity index 100% rename from tests/data/tagged_codelist/tag_species.yaml rename to tests/data/codelist/tagged_codelist/tag_species.yaml diff --git a/tests/data/variable_codelist_complex_attr/variable_complex_attr.yaml b/tests/data/codelist/variable_codelist_complex_attr/variable_complex_attr.yaml similarity index 100% rename from tests/data/variable_codelist_complex_attr/variable_complex_attr.yaml rename to tests/data/codelist/variable_codelist_complex_attr/variable_complex_attr.yaml diff --git a/tests/data/nomenclature_configs/dimensions.yaml b/tests/data/config/dimensions.yaml similarity index 100% rename from tests/data/nomenclature_configs/dimensions.yaml rename to tests/data/config/dimensions.yaml diff --git a/tests/data/double_stacked_external_repo/nomenclature.yaml b/tests/data/config/double_stacked_external_repo/nomenclature.yaml similarity index 100% rename from tests/data/double_stacked_external_repo/nomenclature.yaml rename to tests/data/config/double_stacked_external_repo/nomenclature.yaml diff --git a/tests/data/general-config-only-country/nomenclature.yaml b/tests/data/config/general-config-only-country/nomenclature.yaml similarity index 100% rename from tests/data/general-config-only-country/nomenclature.yaml rename to tests/data/config/general-config-only-country/nomenclature.yaml diff --git a/tests/data/general-config-only-nuts/nomenclature.yaml b/tests/data/config/general-config-only-nuts/nomenclature.yaml similarity index 100% rename from tests/data/general-config-only-nuts/nomenclature.yaml rename to tests/data/config/general-config-only-nuts/nomenclature.yaml diff --git a/tests/data/general-config-only/nomenclature.yaml b/tests/data/config/general-config-only/nomenclature.yaml similarity index 100% rename from tests/data/general-config-only/nomenclature.yaml rename to tests/data/config/general-config-only/nomenclature.yaml diff --git a/tests/data/general-config/definitions/region/regions.yaml b/tests/data/config/general-config/definitions/region/regions.yaml similarity index 100% rename from tests/data/general-config/definitions/region/regions.yaml rename to tests/data/config/general-config/definitions/region/regions.yaml diff --git a/tests/data/general-config/nomenclature.yaml b/tests/data/config/general-config/nomenclature.yaml similarity index 100% rename from tests/data/general-config/nomenclature.yaml rename to tests/data/config/general-config/nomenclature.yaml diff --git a/tests/data/nomenclature_configs/hash_and_release.yaml b/tests/data/config/hash_and_release.yaml similarity index 100% rename from tests/data/nomenclature_configs/hash_and_release.yaml rename to tests/data/config/hash_and_release.yaml diff --git a/tests/data/nomenclature_configs/multiple_repos_for_mapping.yaml b/tests/data/config/multiple_repos_for_mapping.yaml similarity index 100% rename from tests/data/nomenclature_configs/multiple_repos_for_mapping.yaml rename to tests/data/config/multiple_repos_for_mapping.yaml diff --git a/tests/data/nomenclature_configs/multiple_repos_per_dimension.yaml b/tests/data/config/multiple_repos_per_dimension.yaml similarity index 100% rename from tests/data/nomenclature_configs/multiple_repos_per_dimension.yaml rename to tests/data/config/multiple_repos_per_dimension.yaml diff --git a/tests/data/nomenclature_configs/unknown_repo.yaml b/tests/data/config/unknown_repo.yaml similarity index 100% rename from tests/data/nomenclature_configs/unknown_repo.yaml rename to tests/data/config/unknown_repo.yaml diff --git a/tests/data/non-default_dimensions_one_empty/definitions/empty/.gitkeep b/tests/data/config/variable/.gitkeep similarity index 100% rename from tests/data/non-default_dimensions_one_empty/definitions/empty/.gitkeep rename to tests/data/config/variable/.gitkeep diff --git a/tests/data/extras_nc/region/regions.yaml b/tests/data/data_structure_definition/custom_dimension_nc/region/regions.yaml similarity index 100% rename from tests/data/extras_nc/region/regions.yaml rename to tests/data/data_structure_definition/custom_dimension_nc/region/regions.yaml diff --git a/tests/data/custom_dimension_nc/scenario/scenarios.yaml b/tests/data/data_structure_definition/custom_dimension_nc/scenario/scenarios.yaml similarity index 100% rename from tests/data/custom_dimension_nc/scenario/scenarios.yaml rename to tests/data/data_structure_definition/custom_dimension_nc/scenario/scenarios.yaml diff --git a/tests/data/stray_tag/definitions/variable/tag_fuel.yaml b/tests/data/data_structure_definition/custom_dimension_nc/variable/tag_fuel.yaml similarity index 100% rename from tests/data/stray_tag/definitions/variable/tag_fuel.yaml rename to tests/data/data_structure_definition/custom_dimension_nc/variable/tag_fuel.yaml diff --git a/tests/data/custom_dimension_nc/variable/variables.yaml b/tests/data/data_structure_definition/custom_dimension_nc/variable/variables.yaml similarity index 100% rename from tests/data/custom_dimension_nc/variable/variables.yaml rename to tests/data/data_structure_definition/custom_dimension_nc/variable/variables.yaml diff --git a/tests/data/structure_validation_fails/definitions/region/regions.yaml b/tests/data/data_structure_definition/extras_nc/region/regions.yaml similarity index 100% rename from tests/data/structure_validation_fails/definitions/region/regions.yaml rename to tests/data/data_structure_definition/extras_nc/region/regions.yaml diff --git a/tests/data/extras_nc/variable/variables.yaml b/tests/data/data_structure_definition/extras_nc/variable/variables.yaml similarity index 100% rename from tests/data/extras_nc/variable/variables.yaml rename to tests/data/data_structure_definition/extras_nc/variable/variables.yaml diff --git a/tests/data/validation_nc/region/regions.yaml b/tests/data/data_structure_definition/validation_nc/region/regions.yaml similarity index 100% rename from tests/data/validation_nc/region/regions.yaml rename to tests/data/data_structure_definition/validation_nc/region/regions.yaml diff --git a/tests/data/validation_nc/variable/tag_fuel.yaml b/tests/data/data_structure_definition/validation_nc/variable/tag_fuel.yaml similarity index 100% rename from tests/data/validation_nc/variable/tag_fuel.yaml rename to tests/data/data_structure_definition/validation_nc/variable/tag_fuel.yaml diff --git a/tests/data/validation_nc/variable/variables.yaml b/tests/data/data_structure_definition/validation_nc/variable/variables.yaml similarity index 100% rename from tests/data/validation_nc/variable/variables.yaml rename to tests/data/data_structure_definition/validation_nc/variable/variables.yaml diff --git a/tests/data/excel_io/validation_nc.xlsx b/tests/data/io/excel_io/validation_nc.xlsx similarity index 100% rename from tests/data/excel_io/validation_nc.xlsx rename to tests/data/io/excel_io/validation_nc.xlsx diff --git a/tests/data/excel_io/validation_nc_duplicates.xlsx b/tests/data/io/excel_io/validation_nc_duplicates.xlsx similarity index 100% rename from tests/data/excel_io/validation_nc_duplicates.xlsx rename to tests/data/io/excel_io/validation_nc_duplicates.xlsx diff --git a/tests/data/excel_io/validation_nc_flat.yaml b/tests/data/io/excel_io/validation_nc_flat.yaml similarity index 100% rename from tests/data/excel_io/validation_nc_flat.yaml rename to tests/data/io/excel_io/validation_nc_flat.yaml diff --git a/tests/data/excel_io/validation_nc_list_arg.xlsx b/tests/data/io/excel_io/validation_nc_list_arg.xlsx similarity index 100% rename from tests/data/excel_io/validation_nc_list_arg.xlsx rename to tests/data/io/excel_io/validation_nc_list_arg.xlsx diff --git a/tests/data/excel_io/validation_nc_list_arg.yaml b/tests/data/io/excel_io/validation_nc_list_arg.yaml similarity index 100% rename from tests/data/excel_io/validation_nc_list_arg.yaml rename to tests/data/io/excel_io/validation_nc_list_arg.yaml diff --git a/tests/data/definitions1/meta/meta_indicators_allowed_values.yaml b/tests/data/meta_validator/definitions1/meta/meta_indicators_allowed_values.yaml similarity index 100% rename from tests/data/definitions1/meta/meta_indicators_allowed_values.yaml rename to tests/data/meta_validator/definitions1/meta/meta_indicators_allowed_values.yaml diff --git a/tests/data/definitions2/meta/meta_indicators_test_data.yaml b/tests/data/meta_validator/definitions2/meta/meta_indicators_test_data.yaml similarity index 100% rename from tests/data/definitions2/meta/meta_indicators_test_data.yaml rename to tests/data/meta_validator/definitions2/meta/meta_indicators_test_data.yaml diff --git a/tests/data/definitions3/meta/meta_indicators_more_data.yaml b/tests/data/meta_validator/definitions3/meta/meta_indicators_more_data.yaml similarity index 100% rename from tests/data/definitions3/meta/meta_indicators_more_data.yaml rename to tests/data/meta_validator/definitions3/meta/meta_indicators_more_data.yaml diff --git a/tests/data/region_aggregation/excel_mapping_reference.yaml b/tests/data/region_processing/region_aggregation/excel_mapping_reference.yaml similarity index 100% rename from tests/data/region_aggregation/excel_mapping_reference.yaml rename to tests/data/region_processing/region_aggregation/excel_mapping_reference.yaml diff --git a/tests/data/region_aggregation/excel_model_registration.xlsx b/tests/data/region_processing/region_aggregation/excel_model_registration.xlsx similarity index 100% rename from tests/data/region_aggregation/excel_model_registration.xlsx rename to tests/data/region_processing/region_aggregation/excel_model_registration.xlsx diff --git a/tests/data/region_aggregation/illegal_mapping_conflict_regions.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_conflict_regions.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_conflict_regions.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_conflict_regions.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_duplicate_common.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_duplicate_common.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_duplicate_common.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_duplicate_common.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_illegal_attribute.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_illegal_attribute.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_illegal_attribute.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_illegal_attribute.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_invalid_format_dict.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_invalid_format_dict.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_invalid_format_dict.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_invalid_format_dict.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_model_only.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_model_only.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_model_only.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_model_only.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_native_duplicate_key.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_native_duplicate_key.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_native_duplicate_key.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_native_duplicate_key.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_native_rename_key_conflict.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_native_rename_key_conflict.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_native_rename_key_conflict.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_native_rename_key_conflict.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_native_rename_target_conflict_1.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_native_rename_target_conflict_1.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_native_rename_target_conflict_1.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_native_rename_target_conflict_1.yaml diff --git a/tests/data/region_aggregation/illegal_mapping_native_rename_target_conflict_2.yaml b/tests/data/region_processing/region_aggregation/illegal_mapping_native_rename_target_conflict_2.yaml similarity index 100% rename from tests/data/region_aggregation/illegal_mapping_native_rename_target_conflict_2.yaml rename to tests/data/region_processing/region_aggregation/illegal_mapping_native_rename_target_conflict_2.yaml diff --git a/tests/data/region_aggregation/working_mapping.yaml b/tests/data/region_processing/region_aggregation/working_mapping.yaml similarity index 100% rename from tests/data/region_aggregation/working_mapping.yaml rename to tests/data/region_processing/region_aggregation/working_mapping.yaml diff --git a/tests/data/regionprocessor_duplicate/mapping_1.yaml b/tests/data/region_processing/regionprocessor_duplicate/mapping_1.yaml similarity index 100% rename from tests/data/regionprocessor_duplicate/mapping_1.yaml rename to tests/data/region_processing/regionprocessor_duplicate/mapping_1.yaml diff --git a/tests/data/regionprocessor_duplicate/mapping_2.yaml b/tests/data/region_processing/regionprocessor_duplicate/mapping_2.yaml similarity index 100% rename from tests/data/regionprocessor_duplicate/mapping_2.yaml rename to tests/data/region_processing/regionprocessor_duplicate/mapping_2.yaml diff --git a/tests/data/regionprocessor_exclude_region_overlap/exclude_common_overlap.yaml b/tests/data/region_processing/regionprocessor_exclude_region_overlap/exclude_common_overlap.yaml similarity index 100% rename from tests/data/regionprocessor_exclude_region_overlap/exclude_common_overlap.yaml rename to tests/data/region_processing/regionprocessor_exclude_region_overlap/exclude_common_overlap.yaml diff --git a/tests/data/regionprocessor_exclude_region_overlap/exclude_native_overlap.yaml b/tests/data/region_processing/regionprocessor_exclude_region_overlap/exclude_native_overlap.yaml similarity index 100% rename from tests/data/regionprocessor_exclude_region_overlap/exclude_native_overlap.yaml rename to tests/data/region_processing/regionprocessor_exclude_region_overlap/exclude_native_overlap.yaml diff --git a/tests/data/regionprocessor_not_defined/mapping_1.yaml b/tests/data/region_processing/regionprocessor_not_defined/mapping_1.yaml similarity index 100% rename from tests/data/regionprocessor_not_defined/mapping_1.yaml rename to tests/data/region_processing/regionprocessor_not_defined/mapping_1.yaml diff --git a/tests/data/regionprocessor_not_defined/mapping_2.yaml b/tests/data/region_processing/regionprocessor_not_defined/mapping_2.yaml similarity index 100% rename from tests/data/regionprocessor_not_defined/mapping_2.yaml rename to tests/data/region_processing/regionprocessor_not_defined/mapping_2.yaml diff --git a/tests/data/regionprocessor_unexpected_region/model_a.yaml b/tests/data/region_processing/regionprocessor_unexpected_region/model_a.yaml similarity index 100% rename from tests/data/regionprocessor_unexpected_region/model_a.yaml rename to tests/data/region_processing/regionprocessor_unexpected_region/model_a.yaml diff --git a/tests/data/regionprocessor_working/mapping_1.yml b/tests/data/region_processing/regionprocessor_working/mapping_1.yml similarity index 100% rename from tests/data/regionprocessor_working/mapping_1.yml rename to tests/data/region_processing/regionprocessor_working/mapping_1.yml diff --git a/tests/data/regionprocessor_working/mapping_2.yaml b/tests/data/region_processing/regionprocessor_working/mapping_2.yaml similarity index 100% rename from tests/data/regionprocessor_working/mapping_2.yaml rename to tests/data/region_processing/regionprocessor_working/mapping_2.yaml diff --git a/tests/test_cli.py b/tests/test_cli.py index 86c5b8d9..dd1b3422 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -15,6 +15,8 @@ from conftest import TEST_DATA_DIR +MODULE_TEST_DATA_DIR = TEST_DATA_DIR / "cli" + runner = CliRunner() @@ -54,7 +56,11 @@ def test_cli_valid_yaml(): """Check that CLI runs through, when all yaml files in `path` can be parsed without errors""" result_valid = runner.invoke( - cli, ["validate-yaml", str(TEST_DATA_DIR / "duplicate_code_raises")] + cli, + [ + "validate-yaml", + str(TEST_DATA_DIR / "codelist" / "duplicate_code_raises"), + ], ) assert result_valid.exit_code == 0 @@ -62,12 +68,12 @@ def test_cli_valid_yaml(): def test_cli_valid_yaml_fails(): """Check that CLI raises expected error when parsing an invalid yaml""" result_invalid = runner.invoke( - cli, ["validate-yaml", str(TEST_DATA_DIR / "invalid_yaml")] + cli, ["validate-yaml", str(MODULE_TEST_DATA_DIR / "invalid_yaml")] ) assert result_invalid.exit_code == 1 match = "Parsing the yaml files failed. Please check the log for details." with pytest.raises(AssertionError, match=match): - assert_valid_yaml(TEST_DATA_DIR / "invalid_yaml") + assert_valid_yaml(MODULE_TEST_DATA_DIR / "invalid_yaml") def test_cli_valid_project_path(): @@ -81,7 +87,13 @@ def test_cli_valid_project(): """Check that CLI runs through with existing "definitions" and "mappings" directory""" result_valid = runner.invoke( - cli, ["validate-project", str(TEST_DATA_DIR / "structure_validation")] + cli, + [ + "validate-project", + str( + MODULE_TEST_DATA_DIR / "structure_validation", + ), + ], ) assert result_valid.exit_code == 0 @@ -89,7 +101,11 @@ def test_cli_valid_project(): def test_cli_invalid_region(): """Test that errors are correctly propagated""" obs = runner.invoke( - cli, ["validate-project", str(TEST_DATA_DIR / "structure_validation_fails")] + cli, + [ + "validate-project", + str(MODULE_TEST_DATA_DIR / "structure_validation_fails"), + ], ) assert obs.exit_code == 1 assert isinstance(obs.exception, pydantic.ValidationError) @@ -100,7 +116,7 @@ def test_cli_valid_project_fails(): """Check that CLI expected error when "definitions" directory doesn't exist""" path = TEST_DATA_DIR / "invalid_yaml" / "definitions" result_invalid = runner.invoke( - cli, ["validate-project", str(TEST_DATA_DIR / "invalid_yaml")] + cli, ["validate-project", str(MODULE_TEST_DATA_DIR / "invalid_yaml")] ) assert result_invalid.exit_code == 1 @@ -109,7 +125,7 @@ def print_helper(_path): with pytest.raises(NotADirectoryError, match=print_helper(path)): assert_valid_structure( - TEST_DATA_DIR / "invalid_yaml", "mappings", "definitions" + MODULE_TEST_DATA_DIR / "invalid_yaml", "mappings", "definitions" ) @@ -120,7 +136,7 @@ def test_cli_non_default_folders(): cli, [ "validate-project", - str(TEST_DATA_DIR / "non-default_folders"), + str(MODULE_TEST_DATA_DIR / "non-default_folders"), "--definitions", "def", "--mappings", @@ -134,7 +150,13 @@ def test_cli_non_default_folders_fails(): """Check that CLI raises expected error when non-default "definitions" and "mappings" directory names are not given""" result_valid = runner.invoke( - cli, ["validate-project", str(TEST_DATA_DIR / "non-default_folders")] + cli, + [ + "validate-project", + str( + MODULE_TEST_DATA_DIR / "non-default_folders", + ), + ], ) assert result_valid.exit_code == 1 @@ -146,7 +168,7 @@ def test_cli_wrong_definitions_name(): cli, [ "validate-project", - str(TEST_DATA_DIR / "structure_validation"), + str(MODULE_TEST_DATA_DIR / "structure_validation"), "--definitions", "def", ], @@ -161,7 +183,7 @@ def test_cli_custom_dimensions_runs(): cli, [ "validate-project", - str(TEST_DATA_DIR / "non-default_dimensions"), + str(MODULE_TEST_DATA_DIR / "non-default_dimensions"), "--dimension", "variable", "--dimension", @@ -181,7 +203,7 @@ def test_cli_custom_dimensions_fails(): cli, [ "validate-project", - str(TEST_DATA_DIR / "non-default_dimensions"), + str(MODULE_TEST_DATA_DIR / "non-default_dimensions"), "--dimension", "foo", ], @@ -199,7 +221,7 @@ def test_cli_empty_dimensions_run(): cli, [ "validate-project", - str(TEST_DATA_DIR / "non-default_dimensions_one_empty"), + str(MODULE_TEST_DATA_DIR / "non-default_dimensions_one_empty"), "--dimension", "variable", "--dimension", @@ -214,7 +236,10 @@ def test_cli_empty_dimensions_fails(): result_invalid = runner.invoke( cli, - ["validate-project", str(TEST_DATA_DIR / "non-default_dimensions_one_empty")], + [ + "validate-project", + str(MODULE_TEST_DATA_DIR / "non-default_dimensions_one_empty"), + ], ) assert result_invalid.exit_code == 1 assert isinstance(result_invalid.exception, ValueError) @@ -230,7 +255,7 @@ def test_cli_missing_mappings_runs(): cli, [ "validate-project", - str(TEST_DATA_DIR / "structure_validation_no_mappings"), + str(MODULE_TEST_DATA_DIR / "structure_validation_no_mappings"), ], ).exit_code == 0 @@ -244,7 +269,7 @@ def test_cli_missing_mappings_fails(): cli, [ "validate-project", - str(TEST_DATA_DIR / "structure_validation_no_mappings"), + str(MODULE_TEST_DATA_DIR / "structure_validation_no_mappings"), "--mappings", "mappings", ], @@ -276,7 +301,7 @@ def test_cli_empty_definitions_dir(): cli_result = runner.invoke( cli, - ["validate-project", str(TEST_DATA_DIR / "empty_definitions_dir")], + ["validate-project", str(MODULE_TEST_DATA_DIR / "empty_definitions_dir")], ) assert cli_result.exit_code == 1 @@ -343,7 +368,7 @@ def test_cli_export_to_excel(tmpdir): cli, [ "export-definitions", - str(TEST_DATA_DIR / "general-config"), + str(TEST_DATA_DIR / "config" / "general-config"), str(file), ], ).exit_code @@ -363,7 +388,7 @@ def test_cli_add_missing_variables(simple_definition, tmp_path): cli, [ "list-missing-variables", - str(TEST_DATA_DIR / "add-missing-variables" / "data.xlsx"), + str(MODULE_TEST_DATA_DIR / "add-missing-variables" / "data.xlsx"), "--workflow-directory", str(tmp_path), "--target-file", diff --git a/tests/test_codelist.py b/tests/test_codelist.py index ffdc8e9a..885efd1f 100644 --- a/tests/test_codelist.py +++ b/tests/test_codelist.py @@ -15,11 +15,13 @@ from conftest import TEST_DATA_DIR, clean_up_external_repos +MODULE_TEST_DATA_DIR = TEST_DATA_DIR / "codelist" + def test_simple_codelist(): """Import a simple codelist""" codelist = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "simple_codelist" + "variable", MODULE_TEST_DATA_DIR / "simple_codelist" ) assert "Some Variable" in codelist @@ -29,7 +31,7 @@ def test_simple_codelist(): def test_codelist_adding_duplicate_raises(): codelist = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "simple_codelist" + "variable", MODULE_TEST_DATA_DIR / "simple_codelist" ) with raises(ValueError, match="Duplicate item in variable codelist: Some Variable"): codelist["Some Variable"] = "" @@ -52,7 +54,7 @@ def test_codelist_name_key_mismatch(): def test_codelist_to_yaml(): """Cast a codelist to yaml format""" code = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "simple_codelist" + "variable", MODULE_TEST_DATA_DIR / "simple_codelist" ) assert code.to_yaml() == ( @@ -70,7 +72,7 @@ def test_duplicate_code_raises(): match = "Conflicting duplicate items in 'variable' codelist: 'Some Variable'" with raises(ValueError, match=match): VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "duplicate_code_raises" + "variable", MODULE_TEST_DATA_DIR / "duplicate_code_raises" ) @@ -79,14 +81,14 @@ def test_duplicate_tag_raises(): match = "Duplicate item in tag codelist: Tag" with raises(ValueError, match=match): VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "duplicate_tag_raises" + "variable", MODULE_TEST_DATA_DIR / "duplicate_tag_raises" ) def test_tagged_codelist(): """Check that multiple tags in a code are correctly replaced""" code = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "tagged_codelist" + "variable", MODULE_TEST_DATA_DIR / "tagged_codelist" ) exp = { @@ -113,7 +115,7 @@ def test_tagged_codelist(): def test_tags_in_list_attributes(): """Test that tags are replaced correctly in list attributes""" code = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "tagged_codelist" + "variable", MODULE_TEST_DATA_DIR / "tagged_codelist" ) # The test should test that the tags in the definitions in the # tagged_codelist/foo_attr_list_dict.yaml file are expanded correctly. @@ -148,7 +150,7 @@ def test_tags_in_list_attributes(): def test_region_codelist(): """Check replacing top-level hierarchy of yaml file as attribute for regions""" code = RegionCodeList.from_directory( - "region", TEST_DATA_DIR / "region_codelist" / "simple" + "region", MODULE_TEST_DATA_DIR / "region_codelist" / "simple" ) assert "World" in code @@ -164,7 +166,9 @@ def test_region_codelist_nonexisting_country_name(): with pytest.raises(ValueError, match="Region 'Some region' .*: Czech Republic"): RegionCodeList.from_directory( "region", - TEST_DATA_DIR / "region_codelist" / "countries_attribute_non-existing_name", + MODULE_TEST_DATA_DIR + / "region_codelist" + / "countries_attribute_non-existing_name", ) @@ -172,7 +176,7 @@ def test_norway_as_str(): """guard against casting of 'NO' to boolean `False` by PyYAML or pydantic""" region = RegionCodeList.from_directory( "region", - TEST_DATA_DIR / "region_codelist" / "norway_as_bool", + MODULE_TEST_DATA_DIR / "region_codelist" / "norway_as_bool", ) assert region["Norway"].eu_member is False assert region["Norway"].iso2 == "NO" @@ -184,12 +188,13 @@ def test_to_excel(tmpdir): ( VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "validation_nc" / "variable" + "variable", + TEST_DATA_DIR / "data_structure_definition" / "validation_nc" / "variable", ).to_excel(file) ) obs = pd.read_excel(file) - exp = pd.read_excel(TEST_DATA_DIR / "excel_io" / "validation_nc.xlsx") + exp = pd.read_excel(TEST_DATA_DIR / "io" / "excel_io" / "validation_nc.xlsx") pdt.assert_frame_equal(obs, exp) @@ -197,7 +202,7 @@ def test_to_excel(tmpdir): def test_to_csv(): """Check writing to csv""" obs = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "simple_codelist" + "variable", MODULE_TEST_DATA_DIR / "simple_codelist" ).to_csv(lineterminator="\n") exp = ( @@ -213,7 +218,7 @@ def test_stray_tag_fails(): match = r"Unexpected {} in codelist: Primary Energy\|{Feul}" with raises(ValueError, match=match): VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "stray_tag" / "definitions" / "variable" + "variable", MODULE_TEST_DATA_DIR / "stray_tag" / "definitions" / "variable" ) @@ -223,14 +228,16 @@ def test_end_whitespace_fails(): match = "Unexpected whitespace at the end of a scenario code: 'scenario2 '" with raises(ValueError, match=match): CodeList.from_directory( - "scenario", TEST_DATA_DIR / "end_whitespace" / "definitions" / "scenario" + "scenario", + MODULE_TEST_DATA_DIR / "end_whitespace" / "definitions" / "scenario", ) def test_variable_codelist_units(): """Check that the units-attribute works as expected""" codelist = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "validation_nc" / "variable" + "variable", + TEST_DATA_DIR / "data_structure_definition" / "validation_nc" / "variable", ) assert codelist.units == ["", "EJ/yr"] @@ -238,14 +245,14 @@ def test_variable_codelist_units(): def test_variable_codelist_multiple_units(): """Check that multiple units work in a VariableCodeList""" codelist = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "multiple_unit_codelist" + "variable", MODULE_TEST_DATA_DIR / "multiple_unit_codelist" ) assert codelist["Var1"].unit == ["unit1", "unit2"] assert codelist.units == ["unit1", "unit2"] def test_to_excel_read_excel_roundtrip(tmpdir): - codelist_dir = TEST_DATA_DIR / "variable_codelist_complex_attr" + codelist_dir = MODULE_TEST_DATA_DIR / "variable_codelist_complex_attr" # read VariableCodeList exp = VariableCodeList.from_directory("variable", codelist_dir) @@ -269,7 +276,7 @@ def test_to_yaml_from_directory(tmp_path): # read VariableCodeList exp = VariableCodeList.from_directory( - "variable", TEST_DATA_DIR / "variable_codelist_complex_attr" + "variable", MODULE_TEST_DATA_DIR / "variable_codelist_complex_attr" ) exp.to_yaml(tmp_path / "variables.yaml") @@ -285,7 +292,7 @@ def test_RegionCodeList_filter(): # read RegionCodeList rcl = RegionCodeList.from_directory( - "Region", TEST_DATA_DIR / "region_to_filter_codelist" + "Region", MODULE_TEST_DATA_DIR / "region_to_filter_codelist" ) obs = rcl.filter(hierarchy="countries") @@ -307,13 +314,15 @@ def test_RegionCodeList_hierarchy(): """Verifies that the hierarchy method returns a List[str]""" rcl = RegionCodeList.from_directory( - "Region", TEST_DATA_DIR / "region_to_filter_codelist" + "Region", MODULE_TEST_DATA_DIR / "region_to_filter_codelist" ) assert rcl.hierarchy == ["common", "countries"] def test_codelist_general_filter(): - var = CodeList.from_directory("Variable", TEST_DATA_DIR / "general_filtering") + var = CodeList.from_directory( + "Variable", MODULE_TEST_DATA_DIR / "general_filtering" + ) obs = var.filter(required=True) mapping = { "Big Variable": Code( @@ -329,7 +338,9 @@ def test_codelist_general_filter(): def test_codelist_general_filter_multiple_attributes(): - var = CodeList.from_directory("Variable", TEST_DATA_DIR / "general_filtering") + var = CodeList.from_directory( + "Variable", MODULE_TEST_DATA_DIR / "general_filtering" + ) obs = var.filter(some_attribute=True, another_attribute="This is true") mapping = { "Another Variable": Code( @@ -346,7 +357,9 @@ def test_codelist_general_filter_multiple_attributes(): def test_codelist_general_filter_No_Elements(caplog): - var = CodeList.from_directory("Variable", TEST_DATA_DIR / "general_filtering") + var = CodeList.from_directory( + "Variable", MODULE_TEST_DATA_DIR / "general_filtering" + ) caplog.set_level(logging.WARNING) with caplog.at_level(logging.WARNING): obs = var.filter( @@ -359,7 +372,7 @@ def test_codelist_general_filter_No_Elements(caplog): def test_MetaCodeList_from_directory(): - obs = MetaCodeList.from_directory("Meta", TEST_DATA_DIR / "meta") + obs = MetaCodeList.from_directory("Meta", MODULE_TEST_DATA_DIR / "meta") mapping = { "exclude": MetaCode( name="exclude", @@ -378,12 +391,12 @@ def test_MetaCodeList_from_directory(): def test_multiple_external_repos(): nomenclature_config = NomenclatureConfig.from_file( - TEST_DATA_DIR / "nomenclature_configs" / "multiple_repos_per_dimension.yaml" + TEST_DATA_DIR / "config" / "multiple_repos_per_dimension.yaml" ) try: variable_code_list = VariableCodeList.from_directory( "variable", - TEST_DATA_DIR / "nomenclature_configs" / "variable", + TEST_DATA_DIR / "config" / "variable", nomenclature_config, ) assert nomenclature_config.repositories.keys() == { @@ -410,7 +423,7 @@ def test_variable_codelist_with_duplicates_raises(CodeList): ) with raises(ValueError, match=error_string): CodeList.from_directory( - "variable", TEST_DATA_DIR / "duplicate-code-list" / "variable" + "variable", MODULE_TEST_DATA_DIR / "duplicate-code-list" / "variable" ) diff --git a/tests/test_config.py b/tests/test_config.py index 7670424e..70449073 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -5,12 +5,12 @@ from conftest import TEST_DATA_DIR, clean_up_external_repos +MODULE_TEST_DATA_DIR = TEST_DATA_DIR / "config" + def test_hash_and_release_raises(): with raises(ValueError, match="`hash` or `release` can be provided, not both"): - NomenclatureConfig.from_file( - TEST_DATA_DIR / "nomenclature_configs" / "hash_and_release.yaml" - ) + NomenclatureConfig.from_file(MODULE_TEST_DATA_DIR / "hash_and_release.yaml") def test_setting_local_path_raises(): @@ -22,14 +22,12 @@ def test_unknown_repo_raises(): with raises( ValueError, match="Unknown repository {'common-definitions'} in 'region'" ): - NomenclatureConfig.from_file( - TEST_DATA_DIR / "nomenclature_configs" / "unknown_repo.yaml" - ) + NomenclatureConfig.from_file(MODULE_TEST_DATA_DIR / "unknown_repo.yaml") def test_multiple_definition_repos(): nomenclature_config = NomenclatureConfig.from_file( - TEST_DATA_DIR / "nomenclature_configs" / "multiple_repos_per_dimension.yaml" + MODULE_TEST_DATA_DIR / "multiple_repos_per_dimension.yaml" ) try: exp_repos = {"common-definitions", "legacy-definitions"} @@ -47,7 +45,7 @@ def test_codelist_config_set_input(): def test_multiple_mapping_repos(): nomenclature_config = NomenclatureConfig.from_file( - TEST_DATA_DIR / "nomenclature_configs" / "multiple_repos_for_mapping.yaml" + MODULE_TEST_DATA_DIR / "multiple_repos_for_mapping.yaml" ) try: exp_repos = {"common-definitions", "legacy-definitions"} @@ -62,7 +60,7 @@ def test_double_stacked_external_repo_raises(monkeypatch): monkeypatch.setitem( repo.__dict__, "local_path", - TEST_DATA_DIR / "double_stacked_external_repo", + MODULE_TEST_DATA_DIR / "double_stacked_external_repo", ) match = "External repos cannot again refer to external repos" with raises(ValueError, match=match): @@ -70,9 +68,7 @@ def test_double_stacked_external_repo_raises(monkeypatch): def test_config_dimensions(): - config = NomenclatureConfig.from_file( - TEST_DATA_DIR / "nomenclature_configs" / "dimensions.yaml" - ) + config = NomenclatureConfig.from_file(MODULE_TEST_DATA_DIR / "dimensions.yaml") assert set(config.dimensions) == { "scenario", "region", diff --git a/tests/test_definition.py b/tests/test_definition.py index 5dfc1e27..5243c64d 100644 --- a/tests/test_definition.py +++ b/tests/test_definition.py @@ -10,7 +10,7 @@ def test_definition_with_custom_dimension(simple_definition): """Check initializing a DataStructureDefinition with a custom dimension""" obs = DataStructureDefinition( - TEST_DATA_DIR / "custom_dimension_nc", + TEST_DATA_DIR / "data_structure_definition" / "custom_dimension_nc", dimensions=["region", "variable", "scenario"], ) @@ -36,13 +36,13 @@ def test_empty_codelist_raises(): """Check that initializing a DataStructureDefinition with empty CodeList raises""" match = "Empty codelist: region, variable" with pytest.raises(ValueError, match=match): - DataStructureDefinition(TEST_DATA_DIR / "simple_codelist") + DataStructureDefinition(TEST_DATA_DIR / "codelist" / "simple_codelist") @pytest.mark.parametrize("workflow_folder", ["general-config-only", "general-config"]) def test_definition_from_general_config(workflow_folder): obs = DataStructureDefinition( - TEST_DATA_DIR / workflow_folder / "definitions", + TEST_DATA_DIR / "config" / workflow_folder / "definitions", dimensions=["region", "variable"], ) try: @@ -60,7 +60,7 @@ def test_definition_from_general_config(workflow_folder): def test_definition_general_config_country_only(): obs = DataStructureDefinition( - TEST_DATA_DIR / "general-config-only-country" / "definitions" + TEST_DATA_DIR / "config" / "general-config-only-country" / "definitions" ) assert all(region in obs.region for region in ("Austria", "Bolivia", "Kosovo")) @@ -68,7 +68,7 @@ def test_definition_general_config_country_only(): def test_definition_general_config_nuts_only(): """Check that DataStructureDefinition is properly initialised with NUTS region config only""" obs = DataStructureDefinition( - TEST_DATA_DIR / "general-config-only-nuts" / "definitions" + TEST_DATA_DIR / "config" / "general-config-only-nuts" / "definitions" ) assert all(region[:2] in ("AT", "BE", "CZ") for region in obs.region) assert len([region for region in obs.region if region.startswith("AT")]) == 4 @@ -83,7 +83,7 @@ def test_to_excel(simple_definition, tmpdir): simple_definition.to_excel(file) obs = pd.read_excel(file, sheet_name="variable") - exp = pd.read_excel(TEST_DATA_DIR / "excel_io" / "validation_nc.xlsx") + exp = pd.read_excel(TEST_DATA_DIR / "io" / "excel_io" / "validation_nc.xlsx") pd.testing.assert_frame_equal(obs, exp) @@ -92,7 +92,9 @@ def test_to_excel_with_external_repo(tmpdir): file = tmpdir / "testing_export.xlsx" try: - dsd = DataStructureDefinition(TEST_DATA_DIR / "general-config" / "definitions") + dsd = DataStructureDefinition( + TEST_DATA_DIR / "config" / "general-config" / "definitions" + ) dsd.to_excel(file) with pd.ExcelFile(file) as obs: @@ -123,7 +125,7 @@ def test_create_yaml_from_xlsx(input_file, attrs, exp_file, tmpdir): file = tmpdir / "foo.yaml" create_yaml_from_xlsx( - source=TEST_DATA_DIR / "excel_io" / input_file, + source=TEST_DATA_DIR / "io" / "excel_io" / input_file, target=file, sheet_name="variable_definitions", col="variable", @@ -132,7 +134,7 @@ def test_create_yaml_from_xlsx(input_file, attrs, exp_file, tmpdir): with open(file, "r") as f: obs = f.read() - with open(TEST_DATA_DIR / "excel_io" / exp_file, "r") as f: + with open(TEST_DATA_DIR / "io" / "excel_io" / exp_file, "r") as f: exp = f.read() assert obs == exp @@ -142,7 +144,7 @@ def test_create_yaml_from_xlsx_duplicate(): """Check that creating a yaml codelist from xlsx with duplicates raises""" with pytest.raises(ValueError, match="Duplicate values in the codelist:"): create_yaml_from_xlsx( - source=TEST_DATA_DIR / "excel_io" / "validation_nc_duplicates.xlsx", + source=TEST_DATA_DIR / "io" / "excel_io" / "validation_nc_duplicates.xlsx", target="_", sheet_name="duplicate_index_raises", col="Variable", diff --git a/tests/test_definition_variable.py b/tests/test_definition_variable.py index 419673b1..936c4f8b 100644 --- a/tests/test_definition_variable.py +++ b/tests/test_definition_variable.py @@ -4,7 +4,7 @@ from conftest import TEST_DATA_DIR -TEST_FOLDER_VARIABLE = TEST_DATA_DIR / "failing_variable_codelist" +TEST_FOLDER_VARIABLE = TEST_DATA_DIR / "codelist" / "failing_variable_codelist" @pytest.mark.parametrize( diff --git a/tests/test_meta.py b/tests/test_meta.py index 743f19a2..352314b2 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -1,21 +1,22 @@ +import pyam import pytest + from nomenclature.processor.meta import MetaValidator -from pathlib import Path + from conftest import TEST_DATA_DIR -import pyam + +MODULE_TEST_DATA_DIR = TEST_DATA_DIR / "meta_validator" def test_MetaValidator(simple_df): - path = Path(TEST_DATA_DIR / "definitions1/meta") - meta_validator = MetaValidator(path_to_meta_code_list_files=path) + meta_validator = MetaValidator(MODULE_TEST_DATA_DIR / "definitions1" / "meta") exp = simple_df.copy() pyam.testing.assert_iamframe_equal(exp, meta_validator.apply(df=simple_df)) def test_MetaValidator_Meta_Indicator_Error(simple_df): - path = Path(TEST_DATA_DIR / "definitions2" / "meta") simple_df.set_meta(name="not allowed", meta=False) - meta_validator = MetaValidator(path_to_meta_code_list_files=path) + meta_validator = MetaValidator(MODULE_TEST_DATA_DIR / "definitions2" / "meta") match = ( "Invalid meta indicator: 'not allowed'\n" # noqa "Valid meta indicators: 'boolean', 'number', 'string'" # noqa @@ -26,9 +27,8 @@ def test_MetaValidator_Meta_Indicator_Error(simple_df): def test_MetaValidator_Meta_Indicator_Value_Error(simple_df): - path = Path(TEST_DATA_DIR / "definitions3" / "meta") simple_df.set_meta(name="meta_string", meta=3) - meta_validator = MetaValidator(path_to_meta_code_list_files=path) + meta_validator = MetaValidator(MODULE_TEST_DATA_DIR / "definitions3" / "meta") match = ( "Invalid value for meta indicator 'meta_string': '3'\n" # noqa "Allowed values: 'A', 'B'" # noqa diff --git a/tests/test_model_registration_parser.py b/tests/test_model_registration_parser.py index 7298dbec..b446f740 100644 --- a/tests/test_model_registration_parser.py +++ b/tests/test_model_registration_parser.py @@ -7,14 +7,22 @@ def test_parse_model_registration(tmp_path): parse_model_registration( - TEST_DATA_DIR / "region_aggregation" / "excel_model_registration.xlsx", tmp_path + TEST_DATA_DIR + / "region_processing" + / "region_aggregation" + / "excel_model_registration.xlsx", + tmp_path, ) # Test model mapping with open(tmp_path / "Model 1.1_mapping.yaml", "r") as file: obs_model_mapping = yaml.safe_load(file) with open( - TEST_DATA_DIR / "region_aggregation" / "excel_mapping_reference.yaml", "r" + TEST_DATA_DIR + / "region_processing" + / "region_aggregation" + / "excel_mapping_reference.yaml", + "r", ) as file: exp_model_mapping = yaml.safe_load(file) assert obs_model_mapping == exp_model_mapping diff --git a/tests/test_region_aggregation.py b/tests/test_region_aggregation.py index bdeea947..31711225 100644 --- a/tests/test_region_aggregation.py +++ b/tests/test_region_aggregation.py @@ -15,16 +15,19 @@ from conftest import TEST_DATA_DIR, clean_up_external_repos -TEST_FOLDER_REGION_MAPPING = TEST_DATA_DIR / "region_aggregation" +TEST_FOLDER_REGION_PROCESSING = TEST_DATA_DIR / "region_processing" +TEST_FOLDER_REGION_AGGREGATION = TEST_FOLDER_REGION_PROCESSING / "region_aggregation" def test_mapping(): mapping_file = "working_mapping.yaml" # Test that the file is read and represented correctly - obs = RegionAggregationMapping.from_file(TEST_FOLDER_REGION_MAPPING / mapping_file) + obs = RegionAggregationMapping.from_file( + TEST_FOLDER_REGION_AGGREGATION / mapping_file + ) exp = { "model": ["model_a"], - "file": (TEST_FOLDER_REGION_MAPPING / mapping_file).relative_to(Path.cwd()), + "file": (TEST_FOLDER_REGION_AGGREGATION / mapping_file).relative_to(Path.cwd()), "native_regions": [ {"name": "region_a", "rename": "alternative_name_a"}, {"name": "region_b", "rename": "alternative_name_b"}, @@ -86,21 +89,23 @@ def test_illegal_mappings(file, error_msg_pattern): # This is to test a few different failure conditions with pytest.raises(pydantic.ValidationError, match=f"{error_msg_pattern}.*{file}"): - RegionAggregationMapping.from_file(TEST_FOLDER_REGION_MAPPING / file) + RegionAggregationMapping.from_file(TEST_FOLDER_REGION_AGGREGATION / file) def test_mapping_parsing_error(): with pytest.raises(ValueError, match="string indices must be integers"): RegionAggregationMapping.from_file( - TEST_FOLDER_REGION_MAPPING / "illegal_mapping_invalid_format_dict.yaml" + TEST_FOLDER_REGION_AGGREGATION / "illegal_mapping_invalid_format_dict.yaml" ) @pytest.mark.parametrize( "region_processor_path", [ - TEST_DATA_DIR / "regionprocessor_working", - (TEST_DATA_DIR / "regionprocessor_working").relative_to(Path.cwd()), + TEST_FOLDER_REGION_PROCESSING / "regionprocessor_working", + (TEST_FOLDER_REGION_PROCESSING / "regionprocessor_working").relative_to( + Path.cwd() + ), ], ) def test_region_processor_working(region_processor_path, simple_definition): @@ -109,7 +114,7 @@ def test_region_processor_working(region_processor_path, simple_definition): { "model": ["model_a"], "file": ( - TEST_DATA_DIR / "regionprocessor_working/mapping_1.yml" + TEST_FOLDER_REGION_PROCESSING / "regionprocessor_working/mapping_1.yml" ).relative_to(Path.cwd()), "native_regions": [ {"name": "World", "rename": None}, @@ -120,7 +125,7 @@ def test_region_processor_working(region_processor_path, simple_definition): { "model": ["model_b"], "file": ( - TEST_DATA_DIR / "regionprocessor_working/mapping_2.yaml" + TEST_FOLDER_REGION_PROCESSING / "regionprocessor_working/mapping_2.yaml" ).relative_to(Path.cwd()), "native_regions": None, "common_regions": [ @@ -151,7 +156,8 @@ def test_region_processor_not_defined(simple_definition): with pytest.raises(ValueError, match=error_msg): RegionProcessor.from_directory( - TEST_DATA_DIR / "regionprocessor_not_defined", simple_definition + TEST_FOLDER_REGION_PROCESSING / "regionprocessor_not_defined", + simple_definition, ) @@ -159,7 +165,8 @@ def test_region_processor_duplicate_model_mapping(simple_definition): error_msg = ".*model_a.*mapping_(1|2).yaml.*mapping_(1|2).yaml" with pytest.raises(ValueError, match=error_msg): RegionProcessor.from_directory( - TEST_DATA_DIR / "regionprocessor_duplicate", simple_definition + TEST_FOLDER_REGION_PROCESSING / "regionprocessor_duplicate", + simple_definition, ) @@ -176,7 +183,9 @@ def test_region_processor_wrong_args(): match=".*path\n.*does not point to a directory.*", ): RegionProcessor.from_directory( - path=TEST_DATA_DIR / "regionprocessor_working/mapping_1.yml" + path=TEST_FOLDER_REGION_PROCESSING + / "regionprocessor_working" + / "mapping_1.yml" ) @@ -186,7 +195,8 @@ def test_region_processor_multiple_wrong_mappings(simple_definition): with pytest.raises(ValueError, match=msg): RegionProcessor.from_directory( - TEST_DATA_DIR / "region_aggregation", simple_definition + TEST_FOLDER_REGION_AGGREGATION, + simple_definition, ) @@ -201,7 +211,8 @@ def test_region_processor_exclude_model_native_overlap_raises(simple_definition) ), ): RegionProcessor.from_directory( - TEST_DATA_DIR / "regionprocessor_exclude_region_overlap", simple_definition + TEST_FOLDER_REGION_PROCESSING / "regionprocessor_exclude_region_overlap", + simple_definition, ) @@ -218,9 +229,11 @@ def test_region_processor_unexpected_region_raises(): with pytest.raises(ValueError, match="Did not find.*'region_B'.*in.*model_a.yaml"): process( test_df, - dsd := DataStructureDefinition(TEST_DATA_DIR / "region_processing/dsd"), + dsd := DataStructureDefinition( + TEST_DATA_DIR / TEST_DATA_DIR / "region_processing" / "dsd" + ), processor=RegionProcessor.from_directory( - TEST_DATA_DIR / "regionprocessor_unexpected_region", dsd + TEST_FOLDER_REGION_PROCESSING / "regionprocessor_unexpected_region", dsd ), ) @@ -229,12 +242,9 @@ def test_mapping_from_external_repository(): # This test reads both mappings and definitions from an external repository only try: processor = RegionProcessor.from_directory( - TEST_DATA_DIR / "region_processing" / "external_repo_test" / "mappings", + TEST_FOLDER_REGION_PROCESSING / "external_repo_test" / "mappings", dsd := DataStructureDefinition( - TEST_DATA_DIR - / "region_processing" - / "external_repo_test" - / "definitions" + TEST_FOLDER_REGION_PROCESSING / "external_repo_test" / "definitions" ), ) @@ -248,8 +258,8 @@ def test_mapping_from_external_repository(): def test_reverse_region_aggregation(): processor = RegionProcessor.from_directory( - TEST_DATA_DIR / "region_processing" / "complete_processing_list", - DataStructureDefinition(TEST_DATA_DIR / "region_processing/dsd"), + TEST_FOLDER_REGION_PROCESSING / "complete_processing_list", + DataStructureDefinition(TEST_FOLDER_REGION_PROCESSING / "dsd"), ) obs = processor.revert( @@ -278,7 +288,7 @@ def test_reverse_region_aggregation(): def test_model_mapping_from_excel(): - excel_file = TEST_DATA_DIR / "region_aggregation" / "excel_model_registration.xlsx" + excel_file = TEST_FOLDER_REGION_AGGREGATION / "excel_model_registration.xlsx" obs = RegionAggregationMapping.from_file(excel_file) model = "Model 1.1" exp = RegionAggregationMapping( @@ -303,13 +313,13 @@ def test_model_mapping_from_excel(): def test_model_mapping_from_excel_to_yaml(tmp_path): - excel_file = TEST_DATA_DIR / "region_aggregation" / "excel_model_registration.xlsx" + excel_file = TEST_FOLDER_REGION_AGGREGATION / "excel_model_registration.xlsx" # create a yaml mapping from an excel mapping RegionAggregationMapping.from_file(excel_file).to_yaml(tmp_path / "mapping.yaml") obs = RegionAggregationMapping.from_file(tmp_path / "mapping.yaml") exp = RegionAggregationMapping.from_file( - TEST_DATA_DIR / "region_aggregation" / "excel_mapping_reference.yaml" + TEST_FOLDER_REGION_AGGREGATION / "excel_mapping_reference.yaml" ) assert obs == exp diff --git a/tests/test_testing.py b/tests/test_testing.py index 82144048..0c97688b 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -8,7 +8,7 @@ def test_assert_yaml(): """Check that importing a full-fledged (correct) nomenclature definition passes""" - assert_valid_yaml(TEST_DATA_DIR / "validation_nc") + assert_valid_yaml(TEST_DATA_DIR / "data_structure_definition" / "validation_nc") def test_assert_yaml_fails(caplog): @@ -17,7 +17,7 @@ def test_assert_yaml_fails(caplog): # assert that the expected error is raised match = "Parsing the yaml files failed. Please check the log for details." with pytest.raises(AssertionError, match=match): - assert_valid_yaml(TEST_DATA_DIR / "invalid_yaml") + assert_valid_yaml(TEST_DATA_DIR / "cli" / "invalid_yaml") # assert that the expected error message was written to the log log = caplog.record_tuples[0] @@ -32,7 +32,7 @@ def test_hidden_character(): """Check that a non-printable character in any yaml file will raise an error""" match = "scenarios.yaml, line 3, col 12." with pytest.raises(AssertionError, match=match): - assert_valid_yaml(TEST_DATA_DIR / "hidden_character") + assert_valid_yaml(TEST_DATA_DIR / "codelist" / "hidden_character") def test_assert_valid_structure_requiredData_raises(): diff --git a/tests/test_validation.py b/tests/test_validation.py index a06f27fe..9395ef46 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -35,8 +35,9 @@ def test_validation_fails_variable(simple_definition, simple_df, caplog): with pytest.raises(ValueError, match=MATCH_FAIL_VALIDATION): simple_definition.validate(simple_df) assert ( - "Please refer to https://files.ece.iiasa.ac.at/data/data-template.xlsx" - " for the list of allowed variables." in caplog.text + "Please refer to https://files.ece.iiasa.ac.at/data_structure_definition/" + "data_structure_definition-template.xlsx for the list of allowed variables." + in caplog.text ) @@ -47,8 +48,9 @@ def test_validation_fails_unit(simple_definition, simple_df, caplog): with pytest.raises(ValueError, match=MATCH_FAIL_VALIDATION): simple_definition.validate(simple_df) assert ( - "Please refer to https://files.ece.iiasa.ac.at/data/data-template.xlsx" - " for the list of allowed units." in caplog.text + "Please refer to https://files.ece.iiasa.ac.at/data_structure_definition/" + "data_structure_definition-template.xlsx for the list of allowed units." + in caplog.text ) @@ -59,8 +61,9 @@ def test_validation_fails_region(simple_definition, simple_df, caplog): with pytest.raises(ValueError, match=MATCH_FAIL_VALIDATION): simple_definition.validate(simple_df) assert ( - "Please refer to https://files.ece.iiasa.ac.at/data/data-template.xlsx" - " for the list of allowed regions." in caplog.text + "Please refer to https://files.ece.iiasa.ac.at/data_structure_definition/" + "data_structure_definition-template.xlsx for the list of allowed regions." + in caplog.text ) @@ -76,7 +79,7 @@ def test_validation_with_custom_dimension(simple_df): """Check validation with a custom DataStructureDefinition dimension""" definition = DataStructureDefinition( - TEST_DATA_DIR / "custom_dimension_nc", + TEST_DATA_DIR / "data_structure_definition" / "custom_dimension_nc", dimensions=["region", "variable", "scenario"], )