Skip to content

Commit fc7d1d2

Browse files
committed
Added missing unit tests
1 parent c3263f7 commit fc7d1d2

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

syncropatch_export/trace.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ class Trace:
3333
def __init__(self, filepath, json_file: str):
3434
# store file paths
3535
self.filepath = filepath
36-
if json_file[-5:] == '.json':
37-
self.json_file = json_file
38-
else:
39-
self.json_file = json_file + '.json'
36+
self.json_file = json_file
37+
if not json_file.endswith('.json'):
38+
self.json_file += '.json'
4039

4140
# load json file
4241
with open(os.path.join(self.filepath, self.json_file)) as f:

tests/test_trace_class.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ def test_protocol_descriptions(self):
4141
self.assertLess(t_error, 1e-2)
4242
self.assertLess(v_error, 1e-4)
4343

44+
def test_get_protocol_description(self):
45+
a = np.array(self.trace.get_protocol_description())
46+
b = np.array(self.trace.get_voltage_protocol().get_all_sections())
47+
self.assertEqual(a.shape, b.shape)
48+
self.assertTrue(np.all(a == b))
49+
4450
def test_protocol_export(self):
4551
with tempfile.TemporaryDirectory() as d:
4652
protocol = self.trace.get_voltage_protocol()

0 commit comments

Comments
 (0)