diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 27c2104245853d636b4899f9ab370f8dbc4e8e94..3e792092277c9aa7ba0bf09643f4af6ffee68bb0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -59,10 +59,10 @@ test: - python -m coverage html -d $CI_PROJECT_DIR/coverage - cd $CI_PROJECT_DIR/tests/integration - python3 -m coverage run -m unittest test_deposition.py -# - python3 -m unittest test_deposition.py -# - python3 -m unittest test_env_suit.py -# - python3 -m unittest test_survey.py -# - python3 -m unittest test_advisory.py + - python3 -m unittest test_deposition.py + - python3 -m unittest test_env_suit.py + - python3 -m unittest test_survey.py + - python3 -m unittest test_advisory.py - python -m coverage report - python -m coverage html -d $CI_PROJECT_DIR/coverage - ls diff --git a/tests/integration/test_advisory.py b/tests/integration/test_advisory.py index c95e9bd1ad4bfe6c037d17979b48de4de5885033..4c96d87d0e9eb3d6ce5212b5a64de03371f271cf 100644 --- a/tests/integration/test_advisory.py +++ b/tests/integration/test_advisory.py @@ -7,17 +7,35 @@ from integration.integration_test_utils import IntegrationTestUtils class TestEnvSuit(unittest.TestCase): - def setUp(self) -> None: - super().setUp() - default_config = '../test_data/test_deployment/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json' - self.default_config_dict: dict = IntegrationTestUtils.load_json_file(default_config) + TEST_OUT_PATH: str = "not_set" + TEST_RUN_DATE: str = '20221001' + TEST_JOB_DIR: str = "SUMMARY_" + TEST_RUN_DATE - def test_env_suit_standard_inputs_expected_results1(self): + @classmethod + def setUpClass(cls) -> None: + TestEnvSuit.write_temp_run_config_file() + TestEnvSuit.run_advisory_pipeline() + + @staticmethod + def write_temp_run_config_file(): nowstring: str = IntegrationTestUtils.get_now_string() prefix: str = "temp_advisory_" + 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) + TestEnvSuit.TEST_OUT_PATH = run_dict['WorkspacePathout'] + prefix + os.sep + run_dict['WorkspacePathout'] = TestEnvSuit.TEST_OUT_PATH + run_dict['WorkspacePath'] = TestEnvSuit.TEST_OUT_PATH + run_dict['ServerName'] = '' # nothing, as local machine + + IntegrationTestUtils.write_json_file(run_dict, IntegrationTestUtils.TEMP_CONFIG_FILE_PATH) + + @staticmethod + def run_advisory_pipeline(): + os.environ["EMAIL_CRED"] = "../test_data/test_deployment/envs/Cred_gmail.json" from Processor import run_Process, set_log_level args_dict: dict = {} @@ -29,20 +47,30 @@ class TestEnvSuit(unittest.TestCase): args_dict['noupload'] = True set_log_level(args_dict['log_level']) - run_dict: dict = copy.deepcopy(self.default_config_dict) - test_out_path = run_dict['WorkspacePathout'] + prefix + os.sep - run_dict['WorkspacePathout'] = test_out_path - run_dict['WorkspacePath'] = test_out_path - run_dict['ServerName'] = '' # nothing, as local machine + IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_SURVEY_FILE_PATH, TestEnvSuit.TEST_OUT_PATH) + IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_DEPO_FILE_PATH, TestEnvSuit.TEST_OUT_PATH) + IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_ENV_SUIT_FILE_PATH, TestEnvSuit.TEST_OUT_PATH) - IntegrationTestUtils.write_json_file(run_dict, IntegrationTestUtils.TEMP_CONFIG_FILE_PATH) + run_Process(args_dict) - IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_SURVEY_FILE_PATH, test_out_path) - IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_DEPO_FILE_PATH, test_out_path) - IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_ENV_SUIT_FILE_PATH, test_out_path) + def test_standard_run_input_status_success(self): + status_file_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR, "STATUS_SUCCESS") + success_file_exists: bool = os.path.isfile(status_file_path) + self.assertTrue(success_file_exists) - run_Process(args_dict) - self.assertTrue(True) + def test_standard_run_input_all_docs_produced(self): + + east_africa_image_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR, + "tight-layout", + "wheat_rust_advisory_template_EastAfrica_20221001.docx") + ethiopia_image_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.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__': diff --git a/tests/integration/test_env_suit.py b/tests/integration/test_env_suit.py index d2dbd553d2a4e7ade8892f3c0dd5ba7c8fae6543..e55752887d72540e1ee3c8563b40c1190d46e966 100644 --- a/tests/integration/test_env_suit.py +++ b/tests/integration/test_env_suit.py @@ -6,15 +6,15 @@ from integration.integration_test_utils import IntegrationTestUtils class TestEnvSuit(unittest.TestCase): + TEST_OUT_PATH: str = "not_set" TEST_RUN_DATE: str = '20221001' TEST_JOB_DIR: str = "ENVIRONMENT_2.0_" + TEST_RUN_DATE - @classmethod def setUpClass(cls) -> None: TestEnvSuit.write_temp_run_config_file() - # TestEnvSuit.run_env_pipeline() + TestEnvSuit.run_env_pipeline() @staticmethod