From 19ef68a2e106fad7eab7bbfa9166809baf8e0853 Mon Sep 17 00:00:00 2001 From: lb584 <lb584@cam.ac.uk> Date: Wed, 3 May 2023 11:12:11 +0100 Subject: [PATCH] moving the class setup function to half-fat tests, so the TEST_OUT variable is reset for the half-fat tests but not the full-fat ones when being loaded by unittest.main --- tests/integration/full/full_test_deposition.py | 3 ++- tests/integration/full/full_test_env_suit.py | 3 +-- tests/integration/partial/integration_test_utils.py | 6 +++--- tests/integration/partial/run_test_suite.py | 6 +++--- tests/integration/partial/test_advisory.py | 8 ++++++++ tests/integration/partial/test_deposition.py | 10 +++++++++- tests/integration/partial/test_env_suit.py | 8 ++++++++ tests/integration/partial/test_epi.py | 8 ++++++++ tests/integration/partial/test_survey.py | 8 ++++++++ tests/integration/test_suites/advisory_test_suite.py | 4 ---- tests/integration/test_suites/depo_test_suite.py | 4 ---- tests/integration/test_suites/env_suit_test_suite.py | 5 ----- tests/integration/test_suites/epi_test_suite.py | 4 ---- tests/integration/test_suites/survey_test_suite.py | 4 ---- 14 files changed, 50 insertions(+), 31 deletions(-) diff --git a/tests/integration/full/full_test_deposition.py b/tests/integration/full/full_test_deposition.py index cb3772e..71ee3c9 100644 --- a/tests/integration/full/full_test_deposition.py +++ b/tests/integration/full/full_test_deposition.py @@ -18,7 +18,8 @@ class FullTestDeposition(BaseDepoTestSuite.DepoTestSuite): self.set_expected_values() - if IntegrationTestUtils.TEST_OUT_PATH is None \ + path = IntegrationTestUtils.TEST_OUT_PATH + if path is None \ or not os.path.isdir(IntegrationTestUtils.TEST_OUT_PATH): FullTestDeposition.write_temp_run_config_file() FullTestDeposition.run_depo_pipeline() diff --git a/tests/integration/full/full_test_env_suit.py b/tests/integration/full/full_test_env_suit.py index 49181b1..fb51756 100644 --- a/tests/integration/full/full_test_env_suit.py +++ b/tests/integration/full/full_test_env_suit.py @@ -21,7 +21,7 @@ class FullTestEnvSuit(BaseEnvSuitTestSuite.EnvSuitTestSuite): if IntegrationTestUtils.TEST_OUT_PATH is None or not os.path.isdir( IntegrationTestUtils.TEST_OUT_PATH): FullTestEnvSuit.write_temp_run_config_file() - # FullTestEnvSuit.run_env_pipeline() + FullTestEnvSuit.run_env_pipeline() else: print(f"output in {IntegrationTestUtils.TEST_OUT_PATH} already written, skipping rerun") @@ -50,7 +50,6 @@ class FullTestEnvSuit(BaseEnvSuitTestSuite.EnvSuitTestSuite): IntegrationTestUtils.TEST_START_DATE, IntegrationTestUtils.EMAIL_CRED_PATH) - if __name__ == '__main__': _success: bool = IntegrationTestUtils.run_full_integration_test_pipeline(FullTestEnvSuit, test_prefix = "env", diff --git a/tests/integration/partial/integration_test_utils.py b/tests/integration/partial/integration_test_utils.py index 78f8c64..6faef10 100644 --- a/tests/integration/partial/integration_test_utils.py +++ b/tests/integration/partial/integration_test_utils.py @@ -59,8 +59,8 @@ class IntegrationTestUtils: IntegrationTestUtils.DEFAULT_CONFIG_FILE_PATH = _config_file nowstring: str = IntegrationTestUtils.get_now_string() - # prefix: str = f"temp_{test_prefix}_" + nowstring - prefix: str = f"temp_{test_prefix}" + prefix: str = f"temp_{test_prefix}_" + nowstring + # prefix: str = f"temp_{test_prefix}" IntegrationTestUtils.TEST_OUT_PATH = _outdir + prefix + os.sep IntegrationTestUtils.EMAIL_CRED_PATH = _email_cred_path @@ -186,7 +186,7 @@ class IntegrationTestUtils: os.environ["EMAIL_CRED"] = email_cred_path import Processor - reload(Processor) + reload(Processor) # reload the class to reset all variables from Processor import run_Process, set_log_level args_dict: dict = {} diff --git a/tests/integration/partial/run_test_suite.py b/tests/integration/partial/run_test_suite.py index ffbc4a6..cded5c8 100644 --- a/tests/integration/partial/run_test_suite.py +++ b/tests/integration/partial/run_test_suite.py @@ -15,9 +15,9 @@ from integration.partial.test_advisory import TestAdvisory def build_test_runner() -> TestSuite: tests: TestSuite = TestSuite() tests.addTests(TestLoader().loadTestsFromTestCase(TestDeposition)) - # tests.addTests(TestLoader().loadTestsFromTestCase(TestEnvSuit)) - # tests.addTests(TestLoader().loadTestsFromTestCase(TestSurvey)) - # tests.addTests(TestLoader().loadTestsFromTestCase(TestAdvisory)) + tests.addTests(TestLoader().loadTestsFromTestCase(TestEnvSuit)) + tests.addTests(TestLoader().loadTestsFromTestCase(TestSurvey)) + tests.addTests(TestLoader().loadTestsFromTestCase(TestAdvisory)) return tests diff --git a/tests/integration/partial/test_advisory.py b/tests/integration/partial/test_advisory.py index d79c423..9cc1dce 100644 --- a/tests/integration/partial/test_advisory.py +++ b/tests/integration/partial/test_advisory.py @@ -8,6 +8,14 @@ from integration.test_suites.advisory_test_suite import BaseAdvisoryTestSuite class TestAdvisory(BaseAdvisoryTestSuite.AdvisoryTestSuite): + @classmethod + def setUpClass(cls) -> None: + """ + This is overridden in the class setup function to ensure that the value is not set from a previous run + when being run in a TestSuite + """ + IntegrationTestUtils.TEST_OUT_PATH = None + def set_expected_values(self): IntegrationTestUtils.TEST_START_DATE = '20221001' IntegrationTestUtils.TEST_JOB_DIR = "ADVISORY_" + IntegrationTestUtils.TEST_START_DATE diff --git a/tests/integration/partial/test_deposition.py b/tests/integration/partial/test_deposition.py index 3e09ddc..92a6e1f 100644 --- a/tests/integration/partial/test_deposition.py +++ b/tests/integration/partial/test_deposition.py @@ -8,6 +8,14 @@ from integration.test_suites.depo_test_suite import BaseDepoTestSuite class TestDeposition(BaseDepoTestSuite.DepoTestSuite): + @classmethod + def setUpClass(cls) -> None: + """ + This is overridden in the class setup function to ensure that the value is not set from a previous run + when being run in a TestSuite + """ + IntegrationTestUtils.TEST_OUT_PATH = None + def set_expected_values(self): IntegrationTestUtils.TEST_START_DATE = "20221001" @@ -24,7 +32,7 @@ class TestDeposition(BaseDepoTestSuite.DepoTestSuite): if IntegrationTestUtils.TEST_OUT_PATH is None or not os.path.isdir(IntegrationTestUtils.TEST_OUT_PATH): TestDeposition.write_temp_run_config_file() - # TestDeposition.run_depo_pipeline() + TestDeposition.run_depo_pipeline() else: print(f"output in {IntegrationTestUtils.TEST_OUT_PATH} already written, skipping rerun") diff --git a/tests/integration/partial/test_env_suit.py b/tests/integration/partial/test_env_suit.py index 6d65878..8c33a3d 100644 --- a/tests/integration/partial/test_env_suit.py +++ b/tests/integration/partial/test_env_suit.py @@ -8,6 +8,14 @@ from integration.test_suites.env_suit_test_suite import BaseEnvSuitTestSuite class TestEnvSuit(BaseEnvSuitTestSuite.EnvSuitTestSuite): + @classmethod + def setUpClass(cls) -> None: + """ + This is overridden in the class setup function to ensure that the value is not set from a previous run + when being run in a TestSuite + """ + IntegrationTestUtils.TEST_OUT_PATH = None + def set_expected_values(self): IntegrationTestUtils.TEST_START_DATE = "20221001" IntegrationTestUtils.TEST_JOB_DIR = "ENVIRONMENT_2.0_" + IntegrationTestUtils.TEST_START_DATE diff --git a/tests/integration/partial/test_epi.py b/tests/integration/partial/test_epi.py index c9d98d4..46ba53a 100644 --- a/tests/integration/partial/test_epi.py +++ b/tests/integration/partial/test_epi.py @@ -8,6 +8,14 @@ from integration.test_suites.epi_test_suite import BaseEpiTestSuite class TestEpi(BaseEpiTestSuite.EpiTestSuite): + @classmethod + def setUpClass(cls) -> None: + """ + This is overridden in the class setup function to ensure that the value is not set from a previous run + when being run in a TestSuite + """ + IntegrationTestUtils.TEST_OUT_PATH = None + def set_expected_values(self): super().set_expected_values() BaseEpiTestSuite.EpiTestSuite.TEST_START_DATE = '20221001' diff --git a/tests/integration/partial/test_survey.py b/tests/integration/partial/test_survey.py index faca2fc..59d63d5 100644 --- a/tests/integration/partial/test_survey.py +++ b/tests/integration/partial/test_survey.py @@ -8,6 +8,14 @@ from integration.test_suites.survey_test_suite import BaseSurveyTestSuite class TestSurvey(BaseSurveyTestSuite.SurveyTestSuite): + @classmethod + def setUpClass(cls) -> None: + """ + This is overridden in the class setup function to ensure that the value is not set from a previous run + when being run in a TestSuite + """ + IntegrationTestUtils.TEST_OUT_PATH = None + def set_expected_values(self): IntegrationTestUtils.TEST_START_DATE = '20221001' IntegrationTestUtils.TEST_JOB_DIR = "SURVEYDATA_" + IntegrationTestUtils.TEST_START_DATE diff --git a/tests/integration/test_suites/advisory_test_suite.py b/tests/integration/test_suites/advisory_test_suite.py index fe3dfef..abe06ab 100644 --- a/tests/integration/test_suites/advisory_test_suite.py +++ b/tests/integration/test_suites/advisory_test_suite.py @@ -19,10 +19,6 @@ class BaseAdvisoryTestSuite: """ ADVISORY_PROCESSOR_DIR = "ADVISORY" - @classmethod - def setUpClass(cls) -> None: - IntegrationTestUtils.TEST_OUT_PATH = None # reset this value for each new test class - @abc.abstractmethod def set_expected_values(self): self.EXPECTED_EA_IMAGE_COUNT = 0 diff --git a/tests/integration/test_suites/depo_test_suite.py b/tests/integration/test_suites/depo_test_suite.py index 3693879..15f88ea 100644 --- a/tests/integration/test_suites/depo_test_suite.py +++ b/tests/integration/test_suites/depo_test_suite.py @@ -19,10 +19,6 @@ class BaseDepoTestSuite: """ DEPO_PROCESSOR_DIR = "DEPOSITION" - @classmethod - def setUpClass(cls) -> None: - IntegrationTestUtils.TEST_OUT_PATH = None # reset this value for each new test class - @abc.abstractmethod def set_expected_values(self): """ diff --git a/tests/integration/test_suites/env_suit_test_suite.py b/tests/integration/test_suites/env_suit_test_suite.py index ebba559..54d7f2c 100644 --- a/tests/integration/test_suites/env_suit_test_suite.py +++ b/tests/integration/test_suites/env_suit_test_suite.py @@ -19,11 +19,6 @@ class BaseEnvSuitTestSuite: """ ENV_PROCESSOR_DIR = "ENVIRONMENT_2.0" - @classmethod - def setUpClass(cls) -> None: - IntegrationTestUtils.TEST_OUT_PATH = None # reset this value for each new test class - - @abc.abstractmethod def set_expected_values(self): """ diff --git a/tests/integration/test_suites/epi_test_suite.py b/tests/integration/test_suites/epi_test_suite.py index 0a30cd9..c931d7a 100644 --- a/tests/integration/test_suites/epi_test_suite.py +++ b/tests/integration/test_suites/epi_test_suite.py @@ -18,10 +18,6 @@ class BaseEpiTestSuite: """ EPI_PROCESSOR_DIR = "EPI" - @classmethod - def setUpClass(cls) -> None: - IntegrationTestUtils.TEST_OUT_PATH = None # reset this value for each new test class - @abc.abstractmethod def set_expected_values(self): pass diff --git a/tests/integration/test_suites/survey_test_suite.py b/tests/integration/test_suites/survey_test_suite.py index ef1ad71..83ef237 100644 --- a/tests/integration/test_suites/survey_test_suite.py +++ b/tests/integration/test_suites/survey_test_suite.py @@ -18,10 +18,6 @@ class BaseSurveyTestSuite: """ SURVEY_PROCESSOR_DIR = "SURVEYDATA" - @classmethod - def setUpClass(cls) -> None: - IntegrationTestUtils.TEST_OUT_PATH = None # reset this value for each new test class - @abc.abstractmethod def set_expected_values(self): pass -- GitLab