Skip to content
Snippets Groups Projects
Commit 6b87ab29 authored by Lan Dam's avatar Lan Dam
Browse files

add unittest for get_total_files(), modify unittest to match with new error message

parent 2080a747
No related branches found
No related tags found
1 merge request!122allow to select multi folder to load
Pipeline #2552 passed with stage
in 2 minutes and 33 seconds
This commit is part of merge request !122. Comments created here will be created in the context of that merge request.
......@@ -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):
"""
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment