From 7b57f5331e100c259dca6e80f5c4fde5790f2a9b Mon Sep 17 00:00:00 2001 From: lb584 <lb584@cam.ac.uk> Date: Mon, 14 Nov 2022 17:43:10 +0000 Subject: [PATCH] updating epi test --- tests/integration/test_epi.py | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/integration/test_epi.py diff --git a/tests/integration/test_epi.py b/tests/integration/test_epi.py new file mode 100644 index 0000000..18d406d --- /dev/null +++ b/tests/integration/test_epi.py @@ -0,0 +1,72 @@ +import copy +import os +import unittest + +from integration.integration_test_utils import IntegrationTestUtils + + +class TestEpi(unittest.TestCase): + + TEST_OUT_PATH: str = "not_set" + TEST_START_DATE: str = '20221001' + TEST_JOB_DIR: str = "SUMMARY_" + TEST_START_DATE + + @classmethod + def setUpClass(cls) -> None: + TestEpi.write_temp_run_config_files() + TestEpi.unpack_dependencies() + TestEpi.run_advisory_pipeline() + + + @staticmethod + def write_temp_run_config_files(): + nowstring: str = IntegrationTestUtils.get_now_string() + prefix: str = "temp_epi_" + nowstring + # prefix: str = "" + + default_config = IntegrationTestUtils.DEFAULT_CONFIG_FILE_PATH + default_config_dict: dict = IntegrationTestUtils.load_json_file(default_config) + run_dict: dict = copy.deepcopy(default_config_dict) + TestEpi.TEST_OUT_PATH = run_dict['WorkspacePathout'] + prefix + os.sep + run_dict['WorkspacePathout'] = TestEpi.TEST_OUT_PATH + run_dict['WorkspacePath'] = TestEpi.TEST_OUT_PATH + run_dict['ServerName'] = '' # nothing, as local machine + + IntegrationTestUtils.write_json_file(run_dict, IntegrationTestUtils.TEMP_CONFIG_FILE_PATH) + + + @staticmethod + def unpack_dependencies(): + IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_SURVEY_FILE_PATH, TestEpi.TEST_OUT_PATH) + IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_DEPO_FILE_PATH, TestEpi.TEST_OUT_PATH) + IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_ENV_SUIT_FILE_PATH, TestEpi.TEST_OUT_PATH) + + + @staticmethod + def run_advisory_pipeline(): + component = 'Epidemiology' + IntegrationTestUtils.run_pipeline(component, TestEpi.TEST_START_DATE) + + + def test_standard_run_input_status_success(self): + status_file_path = os.path.join(TestEpi.TEST_OUT_PATH, TestEpi.TEST_JOB_DIR, "STATUS_SUCCESS") + success_file_exists: bool = os.path.isfile(status_file_path) + self.assertTrue(success_file_exists) + + def test_standard_run_input_all_docs_produced(self): + + east_africa_image_path = os.path.join(TestEpi.TEST_OUT_PATH, TestEpi.TEST_JOB_DIR, + "tight-layout", + "wheat_rust_advisory_template_EastAfrica_20221001.docx") + ethiopia_image_path = os.path.join(TestEpi.TEST_OUT_PATH, TestEpi.TEST_JOB_DIR, + "tight-layout", + "wheat_rust_advisory_template_Ethiopia_20221001.docx") + + ea_file_exists: bool = os.path.isfile(east_africa_image_path) + eth_file_exists: bool = os.path.isfile(ethiopia_image_path) + self.assertTrue(ea_file_exists) + self.assertTrue(eth_file_exists) + + +if __name__ == '__main__': + unittest.main() -- GitLab