From 3cf35aba02644bf79cbc32b2b1130f0f3eda2b66 Mon Sep 17 00:00:00 2001 From: Anne Griffith Date: Wed, 6 Nov 2024 15:54:21 +0000 Subject: [PATCH 1/3] update path helpers to work for PNP --- src/dev_config.yaml | 4 +- src/user_config.yaml | 4 +- src/utils/path_helpers.py | 82 ++++++++++++++----- tests/test_utils/test_path_helpers.py | 112 +++++++++++++++++--------- 4 files changed, 137 insertions(+), 65 deletions(-) diff --git a/src/dev_config.yaml b/src/dev_config.yaml index a65f8ff2e..de3c180db 100644 --- a/src/dev_config.yaml +++ b/src/dev_config.yaml @@ -9,15 +9,13 @@ global: # Environment settings dev_test : False platform: network # network #whether to load from hdfs, network (Windows) or s3 (CDP) - load_from_feather: False + load_from_feather: True runlog_writer: write_csv: True # Write the runlog to a CSV file write_hdf5: False # Write the runlog to an HDF5 file write_sql: False # Write the runlog to a SQL database display: False # Display the runlog in the terminal log_path: "/bat/res_dev/project_data/logs" -hdfs_paths: - logs_foldername: "/ons/rdbe_dev/logs/run_logs" s3_paths: logs_foldername: "/bat/res_dev/project_data/logs/run_logs" staging_paths: diff --git a/src/user_config.yaml b/src/user_config.yaml index 2a03fcde8..d4934dbb6 100644 --- a/src/user_config.yaml +++ b/src/user_config.yaml @@ -3,6 +3,8 @@ config_validation: path: src/user_config_schema.yaml years: survey_year: 2023 +surveys: + survey_type: "BERD" global: # Staging and validation settings postcode_csv_check: True @@ -21,7 +23,7 @@ global: load_manual_outliers: False load_manual_imputation: False # Backdata output settings - output_backdata: True + output_backdata: False # QA output settings output_full_responses: False output_pnp_full_responses: False diff --git a/src/utils/path_helpers.py b/src/utils/path_helpers.py index 7062b5ca7..e7fd3836d 100644 --- a/src/utils/path_helpers.py +++ b/src/utils/path_helpers.py @@ -5,13 +5,53 @@ PathHelpLogger = logging.getLogger(__name__) +def validate_config_strings(config: dict) -> dict: + """Check that the survey type and platform type config vars are valid. + + Args: + config (dict): The pipeline configuration. + + Returns: + dict: The updated configuration dictionary. + + Raises: + ValueError: If the config settings are not valid. + """ + survey_type = config["surveys"]["survey_type"] + survey_type = survey_type.upper() + valid_survey_types = ["BERD", "PNP"] + + if survey_type not in valid_survey_types: + raise ValueError( + f"Survey type {survey_type} is not valid- it must be one of " + f"{valid_survey_types}" + ) + + platform = config["global"]["platform"] + platform = platform.lower() + valid_platforms = ["network", "s3"] + + if platform not in valid_platforms: + raise ValueError( + f"Platform {platform} is not valid- it must be one of {valid_platforms}" + ) + + config["surveys"]["survey_type"] = survey_type + config["global"]["platform"] = platform + return config + + def get_paths(config: dict) -> dict: """Return either network_paths or hdfs_paths despending on the environment.""" platform = config["global"]["platform"] + survey = config["surveys"]["survey_type"] + + # select either network_paths or s3_paths from the config, depending on platform, paths = config[f"{platform}_paths"] paths["year"] = config["years"]["survey_year"] - paths["berd_path"] = os.path.join(paths["root"], f"{paths['year']}_surveys/BERD/") - paths["pnp_path"] = os.path.join(paths["root"], f"{paths['year']}_surveys/PNP/") + paths["survey_path"] = os.path.join( + paths["root"], f"{paths['year']}_surveys/{survey}/" + ) return paths @@ -28,11 +68,11 @@ def create_module_config(config: dict, module_name: str) -> dict: dict: A dictionary with all the paths needed for the specified module. """ paths = get_paths(config) - berd_path = paths["berd_path"] + survey_path = paths["survey_path"] module_conf = config[f"{module_name}_paths"] # add the folder to the BERD path - folder_path = os.path.join(berd_path, module_conf["folder"]) + folder_path = os.path.join(survey_path, module_conf["folder"]) # we next prefix the folder path to the imputation paths. module_dict = { @@ -83,7 +123,7 @@ def create_staging_config(config: dict) -> dict: dict: A configuration dictionary will all paths needed for staging. """ paths = get_paths(config) - berd_path = paths["berd_path"] + surv_path = paths["survey_path"] staging_dict = create_module_config(config, "staging") @@ -92,11 +132,8 @@ def create_staging_config(config: dict) -> dict: staging_dict["updated_snapshot_path"] = paths["updated_snapshot_path"] staging_dict["postcode_masterlist"] = paths["postcode_masterlist"] staging_dict["backdata_path"] = paths["backdata_path"] - staging_dict[ - "pnp_staging_qa_path" - ] = f"{paths['pnp_path']}{config['pnp_paths']['staging_qa_path']}" - staging_dict["manual_outliers_path"] = f"{berd_path}{paths['manual_outliers_path']}" - staging_dict["manual_imp_trim_path"] = f"{berd_path}{paths['manual_imp_trim_path']}" + staging_dict["manual_outliers_path"] = f"{surv_path}{paths['manual_outliers_path']}" + staging_dict["manual_imp_trim_path"] = f"{surv_path}{paths['manual_imp_trim_path']}" return staging_dict @@ -114,13 +151,13 @@ def create_ni_staging_config(config: dict) -> dict: dict: A dictionary with all the paths needed for the NI staging module. """ paths = get_paths(config) - berd_path = paths["berd_path"] + survey_path = paths["survey_path"] ni_staging_dict = create_module_config(config, "ni") # add in the path to the ni_full_responses ni_path = paths["ni_full_responses_path"] - ni_staging_dict["ni_full_responses"] = os.path.join(berd_path, ni_path) + ni_staging_dict["ni_full_responses"] = os.path.join(survey_path, ni_path) return ni_staging_dict @@ -172,18 +209,18 @@ def create_freezing_config(config: dict) -> dict: # now update add freezing paths paths = get_paths(config) - berd_path = paths["berd_path"] + survey_path = paths["survey_path"] freezing_dict["frozen_data_staged_path"] = os.path.join( - berd_path, paths["frozen_data_staged_path"] + survey_path, paths["frozen_data_staged_path"] ) freezing_dict["freezing_changes_to_review_path"] = os.path.join( - berd_path, paths["freezing_changes_to_review_path"] + survey_path, paths["freezing_changes_to_review_path"] ) freezing_dict["freezing_additions_path"] = os.path.join( - berd_path, paths["freezing_additions_path"] + survey_path, paths["freezing_additions_path"] ) freezing_dict["freezing_amendments_path"] = os.path.join( - berd_path, paths["freezing_amendments_path"] + survey_path, paths["freezing_amendments_path"] ) return freezing_dict @@ -202,15 +239,15 @@ def create_construction_config(config: dict) -> dict: # now update add construction paths paths = get_paths(config) - berd_path = paths["berd_path"] + survey_path = paths["survey_path"] construction_dict["all_data_construction_file_path"] = os.path.join( - berd_path, paths["all_data_construction_file_path"] + survey_path, paths["all_data_construction_file_path"] ) construction_dict["construction_file_path_ni"] = os.path.join( - berd_path, paths["construction_file_path_ni"] + survey_path, paths["construction_file_path_ni"] ) construction_dict["postcode_construction_file_path"] = os.path.join( - berd_path, paths["postcode_construction_file_path"] + survey_path, paths["postcode_construction_file_path"] ) return construction_dict @@ -289,6 +326,9 @@ def update_config_with_paths(config: dict, modules: list) -> dict: Returns: dict: The updated configuration dictionary. """ + # First validate config settings for platform and survey type + config = validate_config_strings(config) + config["staging_paths"] = create_staging_config(config) config["freezing_paths"] = create_freezing_config(config) config["ni_paths"] = create_ni_staging_config(config) diff --git a/tests/test_utils/test_path_helpers.py b/tests/test_utils/test_path_helpers.py index 73cbeba04..99dc2573d 100644 --- a/tests/test_utils/test_path_helpers.py +++ b/tests/test_utils/test_path_helpers.py @@ -12,13 +12,16 @@ create_exports_config, update_config_with_paths, snapshot_validation, - snapshot_validation_logger + snapshot_validation_logger, + validate_config_strings, ) @pytest.fixture(scope="module") def config(): config = { + "years": {"survey_year": 2022}, + "surveys": {"survey_type": "PNP"}, "global": {"platform": "network"}, "network_paths": { "root": "R:/DAP_emulation/", @@ -41,7 +44,6 @@ def config(): "freezing_amendments_path": "02_freezing/freezing_updates/updates.csv", "freezing_additions_path": "02_freezing/freezing_updates/additions.csv", }, - "years": {"survey_year": 2022}, "staging_paths": { "folder": "01_staging", "feather_output": "feather", @@ -80,7 +82,6 @@ def config(): "qa_path": "outliers_qa", "auto_outliers_path": "auto_outliers", }, - "pnp_paths": {"staging_qa_path" : "01_staging/pnp_staging_qa"}, "export_paths": {"export_folder": "outgoing_export"}, } @@ -110,8 +111,7 @@ def test_get_paths(config): "freezing_amendments_path": "02_freezing/freezing_updates/updates.csv", "freezing_additions_path": "02_freezing/freezing_updates/additions.csv", "year": 2022, - "berd_path": "R:/DAP_emulation/2022_surveys/BERD/", - "pnp_path": "R:/DAP_emulation/2022_surveys/PNP/", + "survey_path": "R:/DAP_emulation/2022_surveys/PNP/", } network_paths = get_paths(config) @@ -121,20 +121,17 @@ def test_get_paths(config): @pytest.fixture(scope="module") def expected_staging_dict(): expected_staging_dict = { - "feather_output": "R:/DAP_emulation/2022_surveys/BERD/01_staging/feather", + "feather_output": "R:/DAP_emulation/2022_surveys/PNP/01_staging/feather", "snapshot_path": "/2023_snapshots/snapshot_file-202212.json", "updated_snapshot_path": "2023_snapshots/updated_snapshot_file-202212.json", "postcode_masterlist": "postcode_masterlist_path/postcode.csv", "manual_outliers_path": ( - "R:/DAP_emulation/2022_surveys/BERD/07_outliers/man_out/man_out.csv" + "R:/DAP_emulation/2022_surveys/PNP/07_outliers/man_out/man_out.csv" ), "manual_imp_trim_path": ( - "R:/DAP_emulation/2022_surveys/BERD/06_imputation/man_trim/trim_qa.csv" + "R:/DAP_emulation/2022_surveys/PNP/06_imputation/man_trim/trim_qa.csv" ), "backdata_path": "2021_data/backdata.csv", - "pnp_staging_qa_path": ( - "R:/DAP_emulation/2022_surveys/PNP/01_staging/pnp_staging_qa" - ), } return expected_staging_dict @@ -149,13 +146,16 @@ def test_create_staging_config(config, expected_staging_dict): def test_validate_snapshot_files_success(config, caplog): """Tests for staging_validation function.""" - config = {'years' : {'survey_year': 2023,}, - 'global': {'platform': "network"}, - 'network_paths': { 'root': "R:/DAP_emulation/", - 'snapshot_path': "/2023_snapshots/snapshot_file-202312.json", - 'updated_snapshot_path': '2023_snapshots/updated_snapshot_file-202312.json', - } + config = { + 'years': {'survey_year': 2023}, + 'surveys': {'survey_type': 'PNP'}, + 'global': {'platform': "network"}, + 'network_paths': { + 'root': "R:/DAP_emulation/", + 'snapshot_path': "/2023_snapshots/snapshot_file-202312.json", + 'updated_snapshot_path': '2023_snapshots/updated_snapshot_file-202312.json', } + } msg = 'The snapshot paths are valid.' with caplog.at_level(logging.INFO): @@ -165,13 +165,14 @@ def test_validate_snapshot_files_success(config, caplog): def test_validate_snapshot_files_fail(config, caplog): """Tests for staging_validation function.""" config = { - 'years' : {'survey_year': 2023,}, - 'global': {'platform': "network"}, - 'network_paths': {'root': "R:/BERD Results System Development 2023/DAP_emulation/", - 'snapshot_path': "/ons/rdbe_dev/spp_snapshots/2023_snapshots/snapshot-20212-002-b9b6048a-51c9-4669-919a-e92fc6e9c433.json", - 'updated_snapshot_path': '/ons/rdbe_dev/berd_survey/anonymised/v1/snapshot-202312-002.json', - } + 'global': {'platform': "network"}, + 'surveys': {'survey_type': 'PNP'}, + 'network_paths': { + 'root': "R:/PNP Results System Development 2023/DAP_emulation/", + 'snapshot_path': "/ons/rdbe_dev/spp_snapshots/2023_snapshots/snapshot-20212-002-b9b6048a-51c9-4669-919a-e92fc6e9c433.json", + 'updated_snapshot_path': '/ons/rdbe_dev/PNP_survey/anonymised/v1/snapshot-202312-002.json', + } } msg = "2023 is not included in the frozen snapshot path.\n" @@ -183,14 +184,15 @@ def test_validate_snapshot_files_fail(config, caplog): def test_validate_snapshot_files_success_blank(config, caplog): """Tests for staging_validation function.""" config = { - 'years' : {'survey_year': 2023,}, - 'global': {'platform': "network"}, - 'network_paths': {'root': "R:/BERD Results System Development 2023/DAP_emulation/", - 'snapshot_path': "/ons/rdbe_dev/spp_snapshots/2023_snapshots/snapshot-202312-002-b9b6048a-51c9-4669-919a-e92fc6e9c433.json", - 'updated_snapshot_path': "", - } + 'global': {'platform': "network"}, + 'surveys': {'survey_type': 'PNP'}, + 'network_paths': { + 'root': "R:/PNP Results System Development 2023/DAP_emulation/", + 'snapshot_path': "/ons/rdbe_dev/spp_snapshots/2023_snapshots/snapshot-202312-002-b9b6048a-51c9-4669-919a-e92fc6e9c433.json", + 'updated_snapshot_path': "", } + } msg = 'The snapshot paths are valid.\n' with caplog.at_level(logging.INFO): @@ -205,10 +207,10 @@ def test_create_ni_staging_config(config): expected_ni_staging_dict = { "ni_full_responses": ( - "R:/DAP_emulation/2022_surveys/BERD/03_northern_ireland/2021/TEST_ni.csv" + "R:/DAP_emulation/2022_surveys/PNP/03_northern_ireland/2021/TEST_ni.csv" ), "ni_staging_output_path": ( - "R:/DAP_emulation/2022_surveys/BERD/03_northern_ireland/ni_staging_qa" + "R:/DAP_emulation/2022_surveys/PNP/03_northern_ireland/ni_staging_qa" ), } ni_staging_dict = create_ni_staging_config(config) @@ -222,7 +224,7 @@ def test_create_mapping_config(config): expected_mapping_dict = { "postcode_mapper": "R:/DAP_emulation/2022_surveys/mappers/v1/pcodes_2022.csv", "itl_mapper_path": "R:/DAP_emulation/2022_surveys/mappers/v1/itl_2022.csv", - "qa_path": "R:/DAP_emulation/2022_surveys/BERD/05_mapping/mapping_qa", + "qa_path": "R:/DAP_emulation/2022_surveys/PNP/05_mapping/mapping_qa", } mapping_dict = create_mapping_config(config) @@ -232,11 +234,11 @@ def test_create_mapping_config(config): def test_create_construction_config(config): """Test create_construction_config function.""" expected_construction_dict = { - "qa_path": "R:/DAP_emulation/2022_surveys/BERD/04_construction/construction_qa", - "all_data_construction_file_path": "R:/DAP_emulation/2022_surveys/BERD/04_construction/man_con/construction_file.csv", - "postcode_construction_file_path": "R:/DAP_emulation/2022_surveys/BERD/04_construction/man_con/postcode_construction_file.csv", + "qa_path": "R:/DAP_emulation/2022_surveys/PNP/04_construction/construction_qa", + "all_data_construction_file_path": "R:/DAP_emulation/2022_surveys/PNP/04_construction/man_con/construction_file.csv", + "postcode_construction_file_path": "R:/DAP_emulation/2022_surveys/PNP/04_construction/man_con/postcode_construction_file.csv", "construction_file_path_ni": ( - "R:/DAP_emulation/2022_surveys/BERD/04_construction/man_con/con_file_ni.csv" + "R:/DAP_emulation/2022_surveys/PNP/04_construction/man_con/con_file_ni.csv" ), } construction_dict = create_construction_config(config) @@ -257,9 +259,9 @@ def test_create_module_config_imputation_case(config): """Test create_module_config function for the imputation module.""" expected_imputation_dict = { - "qa_path": "R:/DAP_emulation/2022_surveys/BERD/06_imputation/imputation_qa", + "qa_path": "R:/DAP_emulation/2022_surveys/PNP/06_imputation/imputation_qa", "manual_trimming_path": ( - "R:/DAP_emulation/2022_surveys/BERD/06_imputation/manual_trimming" + "R:/DAP_emulation/2022_surveys/PNP/06_imputation/manual_trimming" ), } imputation_dict = create_module_config(config, "imputation") @@ -270,9 +272,9 @@ def test_create_module_config_imputation_case(config): @pytest.fixture(scope="module") def expected_outliers_dict(): expected_outliers_dict = { - "qa_path": "R:/DAP_emulation/2022_surveys/BERD/07_outliers/outliers_qa", + "qa_path": "R:/DAP_emulation/2022_surveys/PNP/07_outliers/outliers_qa", "auto_outliers_path": ( - "R:/DAP_emulation/2022_surveys/BERD/07_outliers/auto_outliers" + "R:/DAP_emulation/2022_surveys/PNP/07_outliers/auto_outliers" ), } return expected_outliers_dict @@ -313,3 +315,33 @@ def test_update_config_with_paths( updated_config["export_paths"] == {"export_folder": "R:/DAP_emulation/outgoing_export/"}, ) + +def test_validate_config_strings_success(config): + """Test validate_config_strings function with valid survey type and platform.""" + config["surveys"]["survey_type"] = "PNP" + config["global"]["platform"] = "network" + updated_config = validate_config_strings(config) + assert updated_config["surveys"]["survey_type"] == "PNP", "Survey type should be PNP" + assert updated_config["global"]["platform"] == "network", "Platform should be network" + + config["surveys"]["survey_type"] = "PNP" + config["global"]["platform"] = "s3" + updated_config = validate_config_strings(config) + assert updated_config["surveys"]["survey_type"] == "PNP", "Survey type should be PNP" + assert updated_config["global"]["platform"] == "s3", "Platform should be s3" + + +def test_validate_config_strings_invalid_survey_type(config): + """Test validate_config_strings function with invalid survey type.""" + config["surveys"]["survey_type"] = "invalid_type" + config["global"]["platform"] = "network" + with pytest.raises(ValueError, match="Survey type INVALID_TYPE is not valid- it must be one of \['BERD', 'PNP'\]"): + validate_config_strings(config) + + +def test_validate_config_strings_invalid_platform(config): + """Test validate_config_strings function with invalid platform.""" + config["surveys"]["survey_type"] = "PNP" + config["global"]["platform"] = "invalid_platform" + with pytest.raises(ValueError, match="Platform invalid_platform is not valid- it must be one of \['network', 's3'\]"): + validate_config_strings(config) From 94c7bcf05f989f7658cfa7fc21ad4c0999cce37c Mon Sep 17 00:00:00 2001 From: Anne Griffith Date: Wed, 6 Nov 2024 17:31:23 +0000 Subject: [PATCH 2/3] 1040 correct unit tests after merge --- tests/test_utils/test_path_helpers.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_utils/test_path_helpers.py b/tests/test_utils/test_path_helpers.py index 40f69a866..536912269 100644 --- a/tests/test_utils/test_path_helpers.py +++ b/tests/test_utils/test_path_helpers.py @@ -169,7 +169,7 @@ def test_validate_snapshot_files_fail(config, caplog): 'survey': {'survey_type': 'PNP', 'survey_year': 2023}, 'global': {'platform': "network"}, 'network_paths': { - 'root': "R:/PNP Results System Development 2023/DAP_emulation/", + 'root': "R:/BERD Results System Development 2023/DAP_emulation/", 'snapshot_path': "/ons/rdbe_dev/spp_snapshots/2023_snapshots/snapshot-20212-002-b9b6048a-51c9-4669-919a-e92fc6e9c433.json", 'updated_snapshot_path': '/ons/rdbe_dev/PNP_survey/anonymised/v1/snapshot-202312-002.json', } @@ -184,10 +184,10 @@ def test_validate_snapshot_files_fail(config, caplog): def test_validate_snapshot_files_success_blank(config, caplog): """Tests for staging_validation function.""" config = { - 'surveys': {'survey_type': 'PNP', 'survey_year': 2023}, + 'survey': {'survey_type': 'PNP', 'survey_year': 2023}, 'global': {'platform': "network"}, 'network_paths': { - 'root': "R:/PNP Results System Development 2023/DAP_emulation/", + 'root': "R:/BERD Results System Development 2023/DAP_emulation/", 'snapshot_path': "/ons/rdbe_dev/spp_snapshots/2023_snapshots/snapshot-202312-002-b9b6048a-51c9-4669-919a-e92fc6e9c433.json", 'updated_snapshot_path': "", } @@ -317,22 +317,22 @@ def test_update_config_with_paths( def test_validate_config_strings_success(config): """Test validate_config_strings function with valid survey type and platform.""" - config["surveys"]["survey_type"] = "PNP" + config["survey"]["survey_type"] = "PNP" config["global"]["platform"] = "network" updated_config = validate_config_strings(config) - assert updated_config["surveys"]["survey_type"] == "PNP", "Survey type should be PNP" + assert updated_config["survey"]["survey_type"] == "PNP", "Survey type should be PNP" assert updated_config["global"]["platform"] == "network", "Platform should be network" - config["surveys"]["survey_type"] = "PNP" + config["survey"]["survey_type"] = "PNP" config["global"]["platform"] = "s3" updated_config = validate_config_strings(config) - assert updated_config["surveys"]["survey_type"] == "PNP", "Survey type should be PNP" + assert updated_config["survey"]["survey_type"] == "PNP", "Survey type should be PNP" assert updated_config["global"]["platform"] == "s3", "Platform should be s3" def test_validate_config_strings_invalid_survey_type(config): """Test validate_config_strings function with invalid survey type.""" - config["surveys"]["survey_type"] = "invalid_type" + config["survey"]["survey_type"] = "invalid_type" config["global"]["platform"] = "network" with pytest.raises(ValueError, match="Survey type INVALID_TYPE is not valid- it must be one of \['BERD', 'PNP'\]"): validate_config_strings(config) @@ -340,7 +340,7 @@ def test_validate_config_strings_invalid_survey_type(config): def test_validate_config_strings_invalid_platform(config): """Test validate_config_strings function with invalid platform.""" - config["surveys"]["survey_type"] = "PNP" + config["survey"]["survey_type"] = "PNP" config["global"]["platform"] = "invalid_platform" with pytest.raises(ValueError, match="Platform invalid_platform is not valid- it must be one of \['network', 's3'\]"): validate_config_strings(config) From 163cf1fa9b707d2f9e01a7283a8c08e1d8538fb7 Mon Sep 17 00:00:00 2001 From: Anne Griffith Date: Thu, 7 Nov 2024 15:13:36 +0000 Subject: [PATCH 3/3] merge in develop --- src/utils/path_helpers.py | 4 ++-- tests/test_utils/test_path_helpers.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/path_helpers.py b/src/utils/path_helpers.py index 5ce986858..8063faf42 100644 --- a/src/utils/path_helpers.py +++ b/src/utils/path_helpers.py @@ -23,8 +23,8 @@ def validate_config_strings(config: dict) -> dict: if survey_type not in valid_survey_types: raise ValueError( - f"Survey type {survey_type} is not valid- it must be one of " - f"{valid_survey_types}" + f"The config setting for survey_type given, {survey_type}, is not valid- " + f"it should be one of {valid_survey_types}" ) platform = config["global"]["platform"] diff --git a/tests/test_utils/test_path_helpers.py b/tests/test_utils/test_path_helpers.py index 536912269..2437ef4b4 100644 --- a/tests/test_utils/test_path_helpers.py +++ b/tests/test_utils/test_path_helpers.py @@ -334,7 +334,7 @@ def test_validate_config_strings_invalid_survey_type(config): """Test validate_config_strings function with invalid survey type.""" config["survey"]["survey_type"] = "invalid_type" config["global"]["platform"] = "network" - with pytest.raises(ValueError, match="Survey type INVALID_TYPE is not valid- it must be one of \['BERD', 'PNP'\]"): + with pytest.raises(ValueError, match="The config setting for survey_type given, INVALID_TYPE, is not valid- it should be one of \['BERD', 'PNP'\]"): validate_config_strings(config)