Skip to content
Snippets Groups Projects
Commit 1206e9e5 authored by Kien Le's avatar Kien Le
Browse files

Add tests for chunk_minmax

parent 725c139b
No related branches found
No related tags found
1 merge request!27Draft: Add tests for functions in handling_data.py
......@@ -827,3 +827,30 @@ class TestDownsample(TestCase):
# This ensures that we don't do two unneeded copy operations.
self.assertIs(times, self.times)
self.assertIs(data, self.data)
class TestChunkMinmax(TestCase):
def setUp(self):
self.times = np.arange(1000)
self.data = np.arange(1000)
def test_data_size_is_multiple_of_requested_points(self):
req_points = 100
times, data = chunk_minmax(self.times, self.data, req_points)
self.assertEqual(times.size, req_points)
self.assertEqual(data.size, req_points)
@patch('sohstationviewer.model.handling_data.downsample', wraps=downsample)
def test_data_size_is_not_multiple_of_requested_points(self,
mock_downsample):
req_points = 102
chunk_minmax(self.times, self.data, req_points)
self.assertTrue(mock_downsample.called)
def test_requested_points_too_small(self):
small_req_points_list = [0, 1]
for req_points in small_req_points_list:
with self.subTest(f'test_requested_points_is_{req_points}'):
times, data = chunk_minmax(self.times, self.data, req_points)
self.assertEqual(times.size, 0)
self.assertEqual(data.size, 0)
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