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

add test to unittest for check_masspos()

parent 44495bea
No related branches found
No related tags found
1 merge request!356Complete check for mass position channels
Pipeline #4319 passed with stage
in 3 minutes and 21 seconds
......@@ -383,38 +383,96 @@ class TestCheckChanWildcardsFormat(BaseTestCase):
class TestCheckMassPos(BaseTestCase):
@classmethod
def setUpClass(cls) -> None:
cls.mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1},
'MP3': {'chan_id': 'MP3', 'samplerate': 1},
'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
cls.sel_key = '1378'
def test_include_mp123(self):
with self.assertRaises(Exception) as context:
check_masspos(self.mp_data, self.sel_key,
include_mp123=True, include_mp456=False)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position 2")
def test_include_mp123_not_include_mp456(self):
with self.subTest("Consist of MP1,MP3"):
mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1},
'MP3': {'chan_id': 'MP3', 'samplerate': 1},
'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(mp_data, self.sel_key,
include_mp123=True, include_mp456=False)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position 2")
with self.subTest("Consist of MP1,MP3,MPE"):
mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1},
'MP3': {'chan_id': 'MP3', 'samplerate': 1},
'MPE': {'chan_id': 'MPE', 'samplerate': 1},
'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(mp_data, self.sel_key,
include_mp123=True, include_mp456=False)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position "
f"2,Z,N")
with self.subTest("Consist of MPB"):
mp_data = {'MPB': {'chan_id': 'MPB', 'samplerate': 1},
'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(mp_data, self.sel_key,
include_mp123=True, include_mp456=False)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position "
f"A,C")
with self.subTest("No MP 123/ZNE/ABC"):
mp_data = {'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(mp_data, self.sel_key,
include_mp123=True, include_mp456=False)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position "
f"1,2,3")
def test_include_mp456(self):
with self.assertRaises(Exception) as context:
check_masspos(self.mp_data, self.sel_key,
include_mp123=False, include_mp456=True)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position 5,6")
def test_include_mp456_not_include456(self):
with self.subTest("Consist of MP4"):
mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1},
'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(mp_data, self.sel_key,
include_mp123=False, include_mp456=True)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position 5,6")
with self.subTest("Consist of MPW"):
mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1},
'MPW': {'chan_id': 'MPW', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(mp_data, self.sel_key,
include_mp123=False, include_mp456=True)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position U,V")
with self.subTest("No MP 456/UVW"):
mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(mp_data, self.sel_key,
include_mp123=False, include_mp456=True)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position "
f"4,5,6")
def test_include_mp123456(self):
mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1},
'MP3': {'chan_id': 'MP3', 'samplerate': 1},
'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
with self.assertRaises(Exception) as context:
check_masspos(self.mp_data, self.sel_key,
check_masspos(mp_data, self.sel_key,
include_mp123=True, include_mp456=True)
self.assertEqual(
str(context.exception),
f"Data set {self.sel_key} doesn't include mass position 2,5,6")
def test_not_include_mp(self):
mp_data = {'MP1': {'chan_id': 'MP1', 'samplerate': 1},
'MP4': {'chan_id': 'MP4', 'samplerate': 1}}
try:
check_masspos(self.mp_data, self.sel_key,
check_masspos(mp_data, self.sel_key,
include_mp123=False, include_mp456=False)
except Exception:
self.fail("check_masspos() raise Exception unexpectedly")
......
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