diff --git a/tests/integration/integration_test_utils.py b/tests/integration/integration_test_utils.py index c7a5c0ddbfcb70698821250a87c6d97537d183ce..c668331891a9f7694a7aabae73d8796343527bad 100644 --- a/tests/integration/integration_test_utils.py +++ b/tests/integration/integration_test_utils.py @@ -1,10 +1,12 @@ import json from datetime import datetime +from zipfile import ZipFile class IntegrationTestUtils: TEMP_CONFIG_FILE_PATH: str = "../test_data/test_deployment/regions/EastAfrica/workspace/temp_config.json" + EXAMPLE_SURVEY_FILE_PATH: str = "../test_data/test_deployment/regions/EastAfrica/resources/coordinator/assets/example_survey_run.zip" @staticmethod def load_json_file(file: str) -> dict: @@ -23,3 +25,10 @@ class IntegrationTestUtils: def get_now_string() -> str: nowstring: str = datetime.today().strftime('%Y-%m-%d_%H%M%S') return nowstring + + + @staticmethod + def unpack_zip(zip_to_unpack: str, out_file: str): + with ZipFile(zip_to_unpack) as zf: # open the zip file + for target_file in zf.namelist(): # check if the file exists in the archive + zf.extract(target_file, out_file) diff --git a/tests/integration/test_survey.py b/tests/integration/test_survey.py index dd5d0426a47f829b5db169c792665a9f51b2e0d7..15852e1ed87d14d073606bc2835f827d8c3087dc 100644 --- a/tests/integration/test_survey.py +++ b/tests/integration/test_survey.py @@ -14,8 +14,8 @@ class TestEnvSuit(unittest.TestCase): def test_env_suit_standard_inputs_expected_results1(self): - # nowstring: str = IntegrationTestUtils.get_now_string() - nowstring: str = "" + nowstring: str = IntegrationTestUtils.get_now_string() + # nowstring: str = "" os.environ["EMAIL_CRED"] = "../test_data/test_deployment/envs/Cred_gmail.json" from Processor import run_Process, set_log_level @@ -29,7 +29,7 @@ class TestEnvSuit(unittest.TestCase): set_log_level(args_dict['log_level']) run_dict: dict = copy.deepcopy(self.default_config_dict) - test_out_path = run_dict['WorkspacePathout'] + nowstring + os.sep + test_out_path = run_dict['WorkspacePathout'] + "temp_" + nowstring + os.sep run_dict['WorkspacePathout'] = test_out_path run_dict['WorkspacePath'] = test_out_path run_dict['Survey']['SkipServerDownload'] = True @@ -39,6 +39,8 @@ class TestEnvSuit(unittest.TestCase): IntegrationTestUtils.write_json_file(run_dict, IntegrationTestUtils.TEMP_CONFIG_FILE_PATH) + IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_SURVEY_FILE_PATH, test_out_path) + run_Process(args_dict) self.assertTrue(True)