diff --git a/tests/integration/integration_test_utils.py b/tests/integration/integration_test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..b4f228a3e6f9f417a3341539cd587d3fb8984ec6 --- /dev/null +++ b/tests/integration/integration_test_utils.py @@ -0,0 +1,23 @@ +import json +from datetime import datetime + + +class IntegrationTestUtils: + + @staticmethod + def load_json_file(file: str) -> dict: + with open(file) as config_file: + config: dict = json.load(config_file) + return config + + + @staticmethod + def write_json_file(values: dict, file: str): + with open(file, 'w') as file: + json.dump(values, file, indent = 4) + + + @staticmethod + def get_now_string() -> str: + nowstring: str = datetime.today().strftime('%Y-%m-%d_%H%M%S') + return nowstring diff --git a/tests/integration/test_deposition.py b/tests/integration/test_deposition.py index 7781c72cc1afe2ac7785c883df26a484cb9bd91c..cfa60697c42adacc4a824459e1578bd27850de15 100644 --- a/tests/integration/test_deposition.py +++ b/tests/integration/test_deposition.py @@ -1,8 +1,8 @@ import copy -import json import os import unittest -from datetime import datetime + +from integration.integration_test_utils import IntegrationTestUtils class TestDeposition(unittest.TestCase): @@ -12,30 +12,12 @@ class TestDeposition(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 = TestDeposition.load_json_file(default_config) + self.default_config_dict: dict = IntegrationTestUtils.load_json_file(default_config) i = 0 - @staticmethod - def load_json_file(file: str) -> dict: - with open(file) as config_file: - config: dict = json.load(config_file) - return config - - - @staticmethod - def write_json_file(values: dict, file: str): - with open(file, 'w') as file: - json.dump(values, file, indent = 4) - - @staticmethod - def get_now_string() -> str: - nowstring: str = datetime.today().strftime('%Y-%m-%d_%H%M%S') - return nowstring - - def test_depo_standard_inputs_expected_results1(self): - nowstring: str = TestDeposition.get_now_string() + nowstring: str = IntegrationTestUtils.get_now_string() os.environ["EMAIL_CRED"] = "../test_data/test_deployment/envs/Cred_gmail.json" from Processor import run_Process, set_log_level @@ -58,7 +40,7 @@ class TestDeposition(unittest.TestCase): run_dict['SubRegionNames'].remove('Kenya') run_dict['Deposition']['EWS-Plotting'].pop('Kenya', None) - TestDeposition.write_json_file(run_dict, self.TEMP_CONFIG_FILE_PATH) + IntegrationTestUtils.write_json_file(run_dict, self.TEMP_CONFIG_FILE_PATH) run_Process(args_dict) self.assertTrue(True) diff --git a/tests/integration/test_env_suit.py b/tests/integration/test_env_suit.py index 9275f9b0d1b4c1f64473c30ad70a81a655f50b2f..f2c45b1521447d2cd7de6db908249c6230c26438 100644 --- a/tests/integration/test_env_suit.py +++ b/tests/integration/test_env_suit.py @@ -1,8 +1,8 @@ import copy import os import unittest -from datetime import datetime +from integration.integration_test_utils import IntegrationTestUtils from integration.test_deposition import TestDeposition @@ -11,11 +11,11 @@ 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 = TestDeposition.load_json_file(default_config) + self.default_config_dict: dict = IntegrationTestUtils.load_json_file(default_config) def test_env_suit_standard_inputs_expected_results1(self): - nowstring: str = TestDeposition.get_now_string() + nowstring: str = IntegrationTestUtils.get_now_string() os.environ["EMAIL_CRED"] = "../test_data/test_deployment/envs/Cred_gmail.json" from Processor import run_Process, set_log_level @@ -41,11 +41,11 @@ class TestEnvSuit(unittest.TestCase): run_dict['SubRegionNames'].remove('Kenya') - TestDeposition.write_json_file(run_dict, TestDeposition.TEMP_CONFIG_FILE_PATH) + IntegrationTestUtils.write_json_file(run_dict, TestDeposition.TEMP_CONFIG_FILE_PATH) run_Process(args_dict) self.assertTrue(True) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()