FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 9cf51cc8 authored by L. Bower's avatar L. Bower
Browse files

adding basic advisory tests

parent 1d47c1c4
No related branches found
No related tags found
No related merge requests found
...@@ -59,10 +59,10 @@ test: ...@@ -59,10 +59,10 @@ test:
- python -m coverage html -d $CI_PROJECT_DIR/coverage - python -m coverage html -d $CI_PROJECT_DIR/coverage
- cd $CI_PROJECT_DIR/tests/integration - cd $CI_PROJECT_DIR/tests/integration
- python3 -m coverage run -m unittest test_deposition.py - python3 -m coverage run -m unittest test_deposition.py
# - python3 -m unittest test_deposition.py - python3 -m unittest test_deposition.py
# - python3 -m unittest test_env_suit.py - python3 -m unittest test_env_suit.py
# - python3 -m unittest test_survey.py - python3 -m unittest test_survey.py
# - python3 -m unittest test_advisory.py - python3 -m unittest test_advisory.py
- python -m coverage report - python -m coverage report
- python -m coverage html -d $CI_PROJECT_DIR/coverage - python -m coverage html -d $CI_PROJECT_DIR/coverage
- ls - ls
......
...@@ -7,17 +7,35 @@ from integration.integration_test_utils import IntegrationTestUtils ...@@ -7,17 +7,35 @@ from integration.integration_test_utils import IntegrationTestUtils
class TestEnvSuit(unittest.TestCase): class TestEnvSuit(unittest.TestCase):
def setUp(self) -> None: TEST_OUT_PATH: str = "not_set"
super().setUp() TEST_RUN_DATE: str = '20221001'
default_config = '../test_data/test_deployment/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json' TEST_JOB_DIR: str = "SUMMARY_" + TEST_RUN_DATE
self.default_config_dict: dict = IntegrationTestUtils.load_json_file(default_config)
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() nowstring: str = IntegrationTestUtils.get_now_string()
prefix: str = "temp_advisory_" + nowstring prefix: str = "temp_advisory_" + nowstring
# prefix: str = "" # 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" os.environ["EMAIL_CRED"] = "../test_data/test_deployment/envs/Cred_gmail.json"
from Processor import run_Process, set_log_level from Processor import run_Process, set_log_level
args_dict: dict = {} args_dict: dict = {}
...@@ -29,20 +47,30 @@ class TestEnvSuit(unittest.TestCase): ...@@ -29,20 +47,30 @@ class TestEnvSuit(unittest.TestCase):
args_dict['noupload'] = True args_dict['noupload'] = True
set_log_level(args_dict['log_level']) set_log_level(args_dict['log_level'])
run_dict: dict = copy.deepcopy(self.default_config_dict) IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_SURVEY_FILE_PATH, TestEnvSuit.TEST_OUT_PATH)
test_out_path = run_dict['WorkspacePathout'] + prefix + os.sep IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_DEPO_FILE_PATH, TestEnvSuit.TEST_OUT_PATH)
run_dict['WorkspacePathout'] = test_out_path IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_ENV_SUIT_FILE_PATH, TestEnvSuit.TEST_OUT_PATH)
run_dict['WorkspacePath'] = test_out_path
run_dict['ServerName'] = '' # nothing, as local machine
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) def test_standard_run_input_status_success(self):
IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_DEPO_FILE_PATH, test_out_path) status_file_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR, "STATUS_SUCCESS")
IntegrationTestUtils.unpack_zip(IntegrationTestUtils.EXAMPLE_ENV_SUIT_FILE_PATH, test_out_path) success_file_exists: bool = os.path.isfile(status_file_path)
self.assertTrue(success_file_exists)
run_Process(args_dict) def test_standard_run_input_all_docs_produced(self):
self.assertTrue(True)
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__': if __name__ == '__main__':
......
...@@ -6,15 +6,15 @@ from integration.integration_test_utils import IntegrationTestUtils ...@@ -6,15 +6,15 @@ from integration.integration_test_utils import IntegrationTestUtils
class TestEnvSuit(unittest.TestCase): class TestEnvSuit(unittest.TestCase):
TEST_OUT_PATH: str = "not_set" TEST_OUT_PATH: str = "not_set"
TEST_RUN_DATE: str = '20221001' TEST_RUN_DATE: str = '20221001'
TEST_JOB_DIR: str = "ENVIRONMENT_2.0_" + TEST_RUN_DATE TEST_JOB_DIR: str = "ENVIRONMENT_2.0_" + TEST_RUN_DATE
@classmethod @classmethod
def setUpClass(cls) -> None: def setUpClass(cls) -> None:
TestEnvSuit.write_temp_run_config_file() TestEnvSuit.write_temp_run_config_file()
# TestEnvSuit.run_env_pipeline() TestEnvSuit.run_env_pipeline()
@staticmethod @staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment