diff --git a/tests/view/plotting/plotting_widget/test_plotting_widget_helper.py b/tests/view/plotting/plotting_widget/test_plotting_widget_helper.py index 72467c3dbb5a60eb7cbe5c3a894d425fc99aa9b1..57a17b968781d3f9e17ac917665b678a2b0694b6 100644 --- a/tests/view/plotting/plotting_widget/test_plotting_widget_helper.py +++ b/tests/view/plotting/plotting_widget/test_plotting_widget_helper.py @@ -5,13 +5,13 @@ from sohstationviewer.view.plotting.plotting_widget.plotting_widget_helper \ import get_total_miny_maxy, get_index_from_data_picked -class TestGetIndexFromTime(TestCase): +class TestGetIndexFromDataPicked(TestCase): @classmethod def setUpClass(cls) -> None: cls.plotting_data = { 'CH1': { - 'times': [np.array([1, 2, 3, 4, 5, 6])], - 'data': [np.array([1, 1, 0, 1, 1, 0])], + 'times': [np.array([1, 2, 3, 4, 5, 6, 6])], + 'data': [np.array([1, 1, 0, 1, 1, 0, 0])], 'chan_db_info': {'plotType': 'upDownDots'} }, 'CH2': { @@ -27,45 +27,51 @@ class TestGetIndexFromTime(TestCase): } def test_time_not_included(self): - real_idx = get_index_from_data_picked( + real_idxes = get_index_from_data_picked( self.plotting_data['CH1'], 7, 1) - self.assertIsNone(real_idx) + self.assertEqual(len(real_idxes), 0) - def test_type_not_need_data_info(self): - # CH3 has plotType='dotForTime' in ["multiColorDots", "dotForTime"]) - real_idx = get_index_from_data_picked( + def test_type_not_need_data_val(self): + # CH3 has plotType='dotForTime' + # which is in ["multiColorDots", "dotForTime"]) + real_idxes = get_index_from_data_picked( self.plotting_data['CH3'], 4, 4) - self.assertEqual(real_idx, 3) + self.assertEqual(real_idxes.tolist(), [3]) - def test_type_need_data_info(self): + def test_type_need_data_val(self): # CH2 has plotType='linesDots' not in ["multiColorDots", "dotForTime"]) with self.subTest('data not match time'): - real_idx = get_index_from_data_picked( + real_idxes = get_index_from_data_picked( self.plotting_data['CH2'], 3, 5) - self.assertIsNone(real_idx) + self.assertEqual(len(real_idxes), 0) with self.subTest('data match 1st value'): - real_idx = get_index_from_data_picked( + real_idxes = get_index_from_data_picked( self.plotting_data['CH2'], 3, 7) - self.assertEqual(real_idx, 2) + self.assertEqual(real_idxes.tolist(), [2]) with self.subTest('data match 2nd value'): - real_idx = get_index_from_data_picked( + real_idxes = get_index_from_data_picked( self.plotting_data['CH2'], 3, 4) - self.assertEqual(real_idx, 3) + self.assertEqual(real_idxes.tolist(), [3]) def test_type_up_down(self): # CH1 has plotType='upDownDots' with self.subTest('data not match time'): - real_idx = get_index_from_data_picked( + real_idxes = get_index_from_data_picked( self.plotting_data['CH1'], 1, -0.5) - self.assertIsNone(real_idx) + self.assertEqual(len(real_idxes), 0) with self.subTest('data=1 match time'): - real_idx = get_index_from_data_picked( + real_idxes = get_index_from_data_picked( self.plotting_data['CH1'], 1, 0.5) - self.assertEqual(real_idx, 0) + self.assertEqual(real_idxes.tolist(), [0]) with self.subTest('data=0 match time'): - real_idx = get_index_from_data_picked( + real_idxes = get_index_from_data_picked( self.plotting_data['CH1'], 3, -0.5) - self.assertEqual(real_idx, 2) + self.assertEqual(real_idxes.tolist(), [2]) + + def test_2_overlapped_points(self): + real_idxes = get_index_from_data_picked( + self.plotting_data['CH1'], 6, -0.5) + self.assertEqual(real_idxes.tolist(), [5, 6]) class TestGetTotalMinyMaxy(TestCase):