From 9f3c984e842c619200eea61310ddc4c227d26d09 Mon Sep 17 00:00:00 2001
From: lb584 <lb584@cam.ac.uk>
Date: Tue, 14 Mar 2023 16:56:47 +0000
Subject: [PATCH] making full integration tests use the same test suite as
 half-fat ones (work ongoing)

---
 tests/integration/test_suites/__init__.py     |  0
 .../test_suites/depo_test_suite.py            | 90 +++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 tests/integration/test_suites/__init__.py
 create mode 100644 tests/integration/test_suites/depo_test_suite.py

diff --git a/tests/integration/test_suites/__init__.py b/tests/integration/test_suites/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/integration/test_suites/depo_test_suite.py b/tests/integration/test_suites/depo_test_suite.py
new file mode 100644
index 0000000..99d6c82
--- /dev/null
+++ b/tests/integration/test_suites/depo_test_suite.py
@@ -0,0 +1,90 @@
+import abc
+import glob
+import os
+import unittest
+
+from integration.partial.integration_test_utils import IntegrationTestUtils
+
+
+class BaseDepoTestSuite:
+    """
+    to prevent the full integrations tests that extend the partial integrations tests running the tests twice,
+    the test suite is nested in a base class, to keep it at a seperate package-level
+    """
+
+
+    class DepoTestSuite(unittest.TestCase):
+        TEST_OUT_PATH: str = None
+        TEST_START_DATE: str = '20221001'
+        TEST_JOB_DIR: str = "DEPOSITION_" + TEST_START_DATE
+
+        """
+        these fields need to be overridden in the tests that use this test suite, override the 
+        'set_expected_values' function below
+        """
+        EA_CSV_COUNT: int = None
+        ETH_CSV_COUNT: int = None
+        EA_PNG_COUNT: int = None
+        ETH_PNG_COUNT: int = None
+
+
+        @abc.abstractmethod
+        def set_expected_values(self):
+            return
+
+
+        def test_standard_run_input_status_success(self):
+            status_file_path = os.path.join(BaseDepoTestSuite.DepoTestSuite.TEST_OUT_PATH,
+                                            BaseDepoTestSuite.DepoTestSuite.TEST_JOB_DIR,
+                                            "STATUS_SUCCESS")
+            success_file_exists: bool = os.path.isfile(status_file_path)
+            self.assertTrue(success_file_exists)
+
+
+        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(BaseDepoTestSuite.DepoTestSuite.TEST_OUT_PATH,
+                                                  BaseDepoTestSuite.DepoTestSuite.TEST_JOB_DIR,
+                                                  "plotting", "eastafrica", "images", "Weekly",
+                                                  "deposition_eastafrica_leaf_rust_total_*_map.png")
+            ethiopia_image_path = os.path.join(BaseDepoTestSuite.DepoTestSuite.TEST_OUT_PATH,
+                                               BaseDepoTestSuite.DepoTestSuite.TEST_JOB_DIR,
+                                               "plotting", "ethiopia", "images", "Weekly",
+                                               "deposition_ethiopia_leaf_rust_total_*_map.png")
+
+            ea_file_exists: bool = len(glob.glob(east_africa_image_path)) > 0
+            eth_file_exists: bool = len(glob.glob(ethiopia_image_path)) > 0
+            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(BaseDepoTestSuite.DepoTestSuite.TEST_OUT_PATH,
+                                                BaseDepoTestSuite.DepoTestSuite.TEST_JOB_DIR,
+                                                "plotting", "eastafrica", "input_csvs", "*.csv")
+            ethiopia_csv_path = os.path.join(BaseDepoTestSuite.DepoTestSuite.TEST_OUT_PATH,
+                                             BaseDepoTestSuite.DepoTestSuite.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(self.EA_CSV_COUNT, ea_csv_count)
+            self.assertEqual(self.ETH_CSV_COUNT, eth_csv_count)
+
+
+        def test_standard_run_all_images_produced(self):
+            east_africa_image_path = os.path.join(BaseDepoTestSuite.DepoTestSuite.TEST_OUT_PATH,
+                                                  BaseDepoTestSuite.DepoTestSuite.TEST_JOB_DIR,
+                                                  "plotting", "eastafrica", "images", "Weekly", "*.png")
+            ethiopia_image_path = os.path.join(BaseDepoTestSuite.DepoTestSuite.TEST_OUT_PATH,
+                                               BaseDepoTestSuite.DepoTestSuite.TEST_JOB_DIR,
+                                               "plotting", "ethiopia", "images", "Weekly", "*.png")
+
+            ea_png_count: int = IntegrationTestUtils.count_files_in_wildcard(east_africa_image_path)
+            eth_png_count: int = IntegrationTestUtils.count_files_in_wildcard(ethiopia_image_path)
+            self.assertEqual(self.EA_PNG_COUNT, ea_png_count)
+            self.assertEqual(self.ETH_PNG_COUNT, eth_png_count)
\ No newline at end of file
-- 
GitLab