diff --git a/tests/test_model/test_handling_data.py b/tests/test_model/test_handling_data.py index 8261d83e4de7d474b90e2756685aa9412143c44d..e387c4fc5cc52237cdb54c395642145548071abf 100644 --- a/tests/test_model/test_handling_data.py +++ b/tests/test_model/test_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)