From 35f5a8a9996a448c5ae1786666685ac755e875d9 Mon Sep 17 00:00:00 2001 From: lb584 <lb584@cam.ac.uk> Date: Mon, 9 Sep 2024 15:05:28 +0100 Subject: [PATCH] adding function to set test outdir as an environemnt variable - so you can change the default location, which is hard-coded --- tests/integration/partial/integration_test_utils.py | 10 ++++++++++ tests/integration/partial/test_advisory.py | 4 ++-- tests/integration/partial/test_deposition.py | 2 +- tests/integration/partial/test_env_suit.py | 2 +- tests/integration/partial/test_epi.py | 2 +- tests/integration/partial/test_survey.py | 4 ++-- .../regions/EastAfrica/full_test_workspace/.gitignore | 1 - .../regions/EastAfrica/workspace/.gitignore | 1 - 8 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 tests/test_data/test_deployment/regions/EastAfrica/full_test_workspace/.gitignore delete mode 100644 tests/test_data/test_deployment/regions/EastAfrica/workspace/.gitignore diff --git a/tests/integration/partial/integration_test_utils.py b/tests/integration/partial/integration_test_utils.py index 91d0fef..b7d31f4 100644 --- a/tests/integration/partial/integration_test_utils.py +++ b/tests/integration/partial/integration_test_utils.py @@ -68,6 +68,16 @@ class IntegrationTestUtils: parser.add_argument('unittest_args', nargs='*') return parser + @staticmethod + def generate_output_path(filename_prefix: str) -> str: + # if an environment variable "TEST_OUTDIR" is set, use that as the output path + if os.getenv("TEST_OUTDIR"): + result = os.getenv("TEST_OUTDIR") + filename_prefix + "/" + else: + result = IntegrationTestUtils.TEST_WORKSPACE_PATH + filename_prefix + "/" + + return result + @staticmethod def run_full_integration_test_pipeline(test_case: [TestCase], test_prefix: str, diff --git a/tests/integration/partial/test_advisory.py b/tests/integration/partial/test_advisory.py index 0e05842..d69f38e 100644 --- a/tests/integration/partial/test_advisory.py +++ b/tests/integration/partial/test_advisory.py @@ -45,7 +45,7 @@ class TestAdvisory(BaseAdvisoryTestSuite.AdvisoryTestSuite): prefix: str = "temp_advisory_" + nowstring # prefix: str = "temp_advisory" - IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.TEST_WORKSPACE_PATH + prefix + "/" + IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.generate_output_path(prefix) os.makedirs(IntegrationTestUtils.TEST_OUT_PATH, exist_ok = True) sys_config_path = IntegrationTestUtils.DEFAULT_SYS_CONFIG_FILE_PATH @@ -57,7 +57,7 @@ class TestAdvisory(BaseAdvisoryTestSuite.AdvisoryTestSuite): run_config = IntegrationTestUtils.DEFAULT_ADVISORY_CONFIG_FILE_PATH run_config_dict: dict = IntegrationTestUtils.load_json_file(run_config) - IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.TEST_WORKSPACE_PATH + prefix + "/" + IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.generate_output_path(prefix) # may be reusing a non-timestamped output file during development, so allow extant TEST_OUT_PATH os.makedirs(IntegrationTestUtils.TEST_OUT_PATH, exist_ok = True) diff --git a/tests/integration/partial/test_deposition.py b/tests/integration/partial/test_deposition.py index 2704f01..62e663d 100644 --- a/tests/integration/partial/test_deposition.py +++ b/tests/integration/partial/test_deposition.py @@ -46,7 +46,7 @@ class TestDeposition(BaseDepoTestSuite.DepoTestSuite): # prefix: str = "temp_depo" # may be reusing a non-timestamped output file during development, so allow extant TEST_OUT_PATH - IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.TEST_WORKSPACE_PATH + prefix + "/" + IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.generate_output_path(prefix) os.makedirs(IntegrationTestUtils.TEST_OUT_PATH, exist_ok = True) sys_config_path = IntegrationTestUtils.DEFAULT_SYS_CONFIG_FILE_PATH diff --git a/tests/integration/partial/test_env_suit.py b/tests/integration/partial/test_env_suit.py index bd51b39..dd00a2b 100644 --- a/tests/integration/partial/test_env_suit.py +++ b/tests/integration/partial/test_env_suit.py @@ -46,7 +46,7 @@ class TestEnvSuit(BaseEnvSuitTestSuite.EnvSuitTestSuite): # prefix: str = "temp_env" # may be reusing a non-timestamped output file during development, so allow extant TEST_OUT_PATH - IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.TEST_WORKSPACE_PATH + prefix + "/" + IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.generate_output_path(prefix) os.makedirs(IntegrationTestUtils.TEST_OUT_PATH, exist_ok = True) sys_config_path = IntegrationTestUtils.DEFAULT_SYS_CONFIG_FILE_PATH diff --git a/tests/integration/partial/test_epi.py b/tests/integration/partial/test_epi.py index 71443cd..b48fe3a 100644 --- a/tests/integration/partial/test_epi.py +++ b/tests/integration/partial/test_epi.py @@ -41,7 +41,7 @@ class TestEpi(BaseEpiTestSuite.EpiTestSuite): prefix: str = "temp_epi_" + nowstring # prefix: str = "temp_epi" - IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.TEST_WORKSPACE_PATH + prefix + "/" + IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.generate_output_path(prefix) os.makedirs(IntegrationTestUtils.TEST_OUT_PATH, exist_ok = True) sys_config_path = IntegrationTestUtils.DEFAULT_SYS_CONFIG_FILE_PATH diff --git a/tests/integration/partial/test_survey.py b/tests/integration/partial/test_survey.py index 42b8c98..9ea063b 100644 --- a/tests/integration/partial/test_survey.py +++ b/tests/integration/partial/test_survey.py @@ -43,7 +43,7 @@ class TestSurvey(BaseSurveyTestSuite.SurveyTestSuite): prefix: str = "temp_survey_" + nowstring # prefix: str = "temp_survey" - IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.TEST_WORKSPACE_PATH + prefix + "/" + IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.generate_output_path(prefix) os.makedirs(IntegrationTestUtils.TEST_OUT_PATH, exist_ok = True) sys_config_path = IntegrationTestUtils.DEFAULT_SYS_CONFIG_FILE_PATH @@ -56,7 +56,7 @@ class TestSurvey(BaseSurveyTestSuite.SurveyTestSuite): run_config = IntegrationTestUtils.DEFAULT_SURVEY_CONFIG_FILE_PATH run_config_dict: dict = IntegrationTestUtils.load_json_file(run_config) run_dict: dict = copy.deepcopy(run_config_dict) - IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.TEST_WORKSPACE_PATH + prefix + "/" + IntegrationTestUtils.TEST_OUT_PATH = IntegrationTestUtils.generate_output_path(prefix) run_dict['WORK_PATH'] = IntegrationTestUtils.TEST_OUT_PATH run_dict['INPUT_PATH'] = IntegrationTestUtils.TEST_OUT_PATH run_dict['OUTPUT_PATH'] = IntegrationTestUtils.TEST_OUT_PATH diff --git a/tests/test_data/test_deployment/regions/EastAfrica/full_test_workspace/.gitignore b/tests/test_data/test_deployment/regions/EastAfrica/full_test_workspace/.gitignore deleted file mode 100644 index 7c89176..0000000 --- a/tests/test_data/test_deployment/regions/EastAfrica/full_test_workspace/.gitignore +++ /dev/null @@ -1 +0,0 @@ -temp_* diff --git a/tests/test_data/test_deployment/regions/EastAfrica/workspace/.gitignore b/tests/test_data/test_deployment/regions/EastAfrica/workspace/.gitignore deleted file mode 100644 index 7c89176..0000000 --- a/tests/test_data/test_deployment/regions/EastAfrica/workspace/.gitignore +++ /dev/null @@ -1 +0,0 @@ -temp_* -- GitLab