From fb18c05a2826e915a595deff02f22abea1881aaf Mon Sep 17 00:00:00 2001 From: Furkan Date: Sat, 12 Oct 2024 13:59:09 +0300 Subject: [PATCH] refactor: update obsolute function name in test_csv.py and add prefix to message mock --- src/tests/test_csv.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tests/test_csv.py b/src/tests/test_csv.py index 8e59072..3016c38 100644 --- a/src/tests/test_csv.py +++ b/src/tests/test_csv.py @@ -17,7 +17,7 @@ def setUp(self): self.config = MagicMock() self.store = DAQJobStoreCSV(self.config) - @patch("daq.store.csv.add_date_to_file_name", return_value="test.csv") + @patch("daq.store.csv.modify_file_path", return_value="test.csv") @patch("builtins.open", new_callable=mock_open) @patch("os.path.exists", return_value=False) @patch("pathlib.Path.touch") @@ -30,16 +30,17 @@ def test_handle_message_new_file( ) message.keys = ["header1", "header2"] message.data = [["row1_col1", "row1_col2"], ["row2_col1", "row2_col2"]] + message.prefix = None self.store.handle_message(message) - mock_add_date.assert_called_once_with("test.csv", True) + mock_add_date.assert_called_once_with("test.csv", True, None) mock_open.assert_called_once_with("test.csv", "a") self.assertIn("test.csv", self.store._open_csv_files) file = self.store._open_csv_files["test.csv"] self.assertEqual(file.write_queue.qsize(), 3) # 1 header + 2 rows - @patch("daq.store.csv.add_date_to_file_name", return_value="test.csv") + @patch("daq.store.csv.modify_file_path", return_value="test.csv") @patch("builtins.open", new_callable=mock_open) @patch("os.path.exists", return_value=True) def test_handle_message_existing_file(self, mock_exists, mock_open, mock_add_date): @@ -49,10 +50,11 @@ def test_handle_message_existing_file(self, mock_exists, mock_open, mock_add_dat ) message.keys = ["header1", "header2"] message.data = [["row1_col1", "row1_col2"], ["row2_col1", "row2_col2"]] + message.prefix = None self.store.handle_message(message) - mock_add_date.assert_called_once_with("test.csv", True) + mock_add_date.assert_called_once_with("test.csv", True, None) mock_open.assert_called_once_with("test.csv", "a") self.assertIn("test.csv", self.store._open_csv_files) file = self.store._open_csv_files["test.csv"]