FAQ | This is a LIVE service | Changelog

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

adding env suit tests

parent 7b06fbbb
No related branches found
No related tags found
No related merge requests found
......@@ -2,5 +2,4 @@
exclude_lines =
if __name__ == .__main__.:
omit =
*/Processor.py
*/__init__.py
\ No newline at end of file
......@@ -14,7 +14,7 @@ class TestDeposition(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
TestDeposition.write_temp_run_config_file()
TestDeposition.run_depo_pipelines()
TestDeposition.run_depo_pipeline()
@staticmethod
......@@ -37,11 +37,11 @@ class TestDeposition(unittest.TestCase):
@staticmethod
def run_depo_pipelines():
def run_depo_pipeline():
os.environ["EMAIL_CRED"] = "../test_data/test_deployment/envs/Cred_gmail.json"
from Processor import run_Process, set_log_level
args_dict: dict = {}
args_dict['component'] = 'Deposition'
args_dict['config_paths'] = [IntegrationTestUtils.TEMP_CONFIG_FILE_PATH]
......
......@@ -6,18 +6,45 @@ 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
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)
def test_env_suit_standard_inputs_expected_results1(self):
@classmethod
def setUpClass(cls) -> None:
TestEnvSuit.write_temp_run_config_file()
# TestEnvSuit.run_env_pipeline()
@staticmethod
def write_temp_run_config_file():
nowstring: str = IntegrationTestUtils.get_now_string()
prefix: str = "temp_depo_" + 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['Environment']['WORK_PATH'] = TestEnvSuit.TEST_OUT_PATH
run_dict['Environment']['INPUT_PATH'] = TestEnvSuit.TEST_OUT_PATH
run_dict['Environment']['OUTPUT_PATH'] = TestEnvSuit.TEST_OUT_PATH
run_dict['ServerName'] = '' # nothing, as local machine
full_server_path = os.path.abspath("../test_data/met_office/env_suit/")
run_dict['Environment']['ServerPathTemplate'] = full_server_path
IntegrationTestUtils.write_json_file(run_dict, IntegrationTestUtils.TEMP_CONFIG_FILE_PATH)
@staticmethod
def run_env_pipeline():
os.environ["EMAIL_CRED"] = "../test_data/test_deployment/envs/Cred_gmail.json"
from Processor import run_Process, set_log_level
args_dict: dict = {}
args_dict['component'] = 'Environment'
args_dict['config_paths'] = [IntegrationTestUtils.TEMP_CONFIG_FILE_PATH]
......@@ -27,23 +54,56 @@ 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'] + "temp_env_" + nowstring + os.sep
run_dict['WorkspacePathout'] = test_out_path
run_dict['WorkspacePath'] = test_out_path
run_dict['Environment']['WORK_PATH'] = test_out_path
run_dict['Environment']['INPUT_PATH'] = test_out_path
run_dict['Environment']['OUTPUT_PATH'] = test_out_path
run_dict['ServerName'] = '' # nothing, as local machine
full_server_path = os.path.abspath("../test_data/met_office/env_suit/")
run_dict['Environment']['ServerPathTemplate'] = full_server_path
run_Process(args_dict)
# run_dict['SubRegionNames'].remove('Kenya')
IntegrationTestUtils.write_json_file(run_dict, IntegrationTestUtils.TEMP_CONFIG_FILE_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_regions_ran(self):
"""
working on the assumption that if there are images for each region, it must have run through
(at least past the region iteration)
"""
east_africa_image_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR,
"plotting", "eastafrica", "images", "Weekly",
"suitability_eastafrica_leaf_rust_total_202210010000_202210070000_map.png")
ethiopia_image_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR,
"plotting", "ethiopia", "images", "Weekly",
"suitability_ethiopia_leaf_rust_total_202210010000_202210070000_map.png")
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)
def test_standard_run_all_input_csvs_produced(self):
east_africa_csv_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR,
"plotting", "eastafrica", "input_csvs", "*.csv")
ethiopia_csv_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR,
"plotting", "ethiopia", "input_csvs", "*.csv")
ea_csv_count: int = IntegrationTestUtils.count_files_in_wildcard(east_africa_csv_path)
eth_csv_count: int = IntegrationTestUtils.count_files_in_wildcard(ethiopia_csv_path)
self.assertEqual(18, ea_csv_count)
self.assertEqual(18, eth_csv_count)
def test_standard_run_all_images_produced(self):
east_africa_image_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR,
"plotting", "eastafrica", "images", "Weekly", "*.png")
ethiopia_image_path = os.path.join(TestEnvSuit.TEST_OUT_PATH, TestEnvSuit.TEST_JOB_DIR,
"plotting", "ethiopia", "images", "Weekly", "*.png")
ea_csv_count: int = IntegrationTestUtils.count_files_in_wildcard(east_africa_image_path)
eth_csv_count: int = IntegrationTestUtils.count_files_in_wildcard(ethiopia_image_path)
self.assertEqual(6, ea_csv_count)
self.assertEqual(6, eth_csv_count)
if __name__ == '__main__':
......
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