From 6b87ab29c1e101e0469c1af53d19d70d82dcc00d Mon Sep 17 00:00:00 2001
From: Lan <ldam@passcal.nmt.edu>
Date: Wed, 10 May 2023 14:47:06 -0600
Subject: [PATCH] add unittest for get_total_files(), modify unittest to match
 with new error message

---
 tests/test_controller/test_processing.py | 13 +++++--------
 tests/test_controller/test_util.py       |  9 +++++++++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/tests/test_controller/test_processing.py b/tests/test_controller/test_processing.py
index 289eb5bbd..74751b31b 100644
--- a/tests/test_controller/test_processing.py
+++ b/tests/test_controller/test_processing.py
@@ -161,8 +161,7 @@ class TestLoadDataAndReadChannels(TestCase):
             self.assertIsNone(load_data('RT130', None, [q330_dir], []))
         output = f.getvalue()
         self.assertIn(
-            f"Dir {q330_dir} "
-            f"can't be read due to error: Traceback",
+            "Data can't be read due to error: Traceback",
             output
         )
         with redirect_stdout(f):
@@ -170,8 +169,7 @@ class TestLoadDataAndReadChannels(TestCase):
                 load_data(self.mseed_dtype, None, [rt130_dir], []))
         output = f.getvalue()
         self.assertIn(
-            f"Dir {rt130_dir} "
-            f"can't be read due to error: Traceback",
+            "Data can't be read due to error: Traceback",
             output
         )
 
@@ -354,10 +352,9 @@ class TestDetectDataType(TestCase):
             detect_data_type([self.dir1.name, self.dir2.name])
         self.assertEqual(
             str(context.exception),
-            f"There are more than one types of data detected:\n"
-            f"{self.dir1.name}: [RT130, _]\n"
-            f"{self.dir2.name}: [Q330, VEP]\n\n"
-            f"Please have only data that related to each other.")
+            "There are more than one types of data detected:\n"
+            "Q330, RT130\n\n"
+            "Please have only one data type for each loading.")
 
     def test_unknown_data_type(self):
         """
diff --git a/tests/test_controller/test_util.py b/tests/test_controller/test_util.py
index e58e8c89b..83bfa6885 100644
--- a/tests/test_controller/test_util.py
+++ b/tests/test_controller/test_util.py
@@ -11,6 +11,7 @@ import string
 from sohstationviewer.controller.util import (
     validate_file,
     validate_dir,
+    get_total_files,
     get_dir_size,
     get_time_6,
     get_time_6_2y,
@@ -202,6 +203,14 @@ class TestValidateDir(TestCase):
             self.fail()
 
 
+class TestGetTotalFiles(TestCase):
+    def test_get_total_files(self):
+        list_of_dir = [os.path.join(TEST_DATA_DIR, 'Centaur-sample'),
+                       os.path.join(TEST_DATA_DIR, 'Q330-sample')]
+        total_files = get_total_files(list_of_dir)
+        self.assertEqual(total_files, 6)
+
+
 class TestGetDirSize(TestCase):
     """Test suite for get_dir_size."""
     def test_files_have_size_zero(self):
-- 
GitLab