From 6d41638ab2fdf645fd5a102253d2cd1695e687e8 Mon Sep 17 00:00:00 2001 From: Ramesh Raghupathy Date: Thu, 12 Dec 2024 21:32:33 -0800 Subject: [PATCH] Iproving coverage --- tests/process-reboot-cause_test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/process-reboot-cause_test.py b/tests/process-reboot-cause_test.py index 3ce48052..c02dfbd9 100644 --- a/tests/process-reboot-cause_test.py +++ b/tests/process-reboot-cause_test.py @@ -99,10 +99,11 @@ def test_get_sorted_reboot_cause_files_error(self, mock_listdir): # Test update_dpu_reboot_cause_to_chassis_state_db @patch("builtins.open", new_callable=mock_open, read_data='{"cause": "Non-Hardware", "comment": "Switch rebooted DPU", "device": "DPU0", "time": "Fri Dec 13 01:12:36 AM UTC 2024", "name": "2024_12_13_01_12_36"}') @patch("process_reboot_cause.device_info.get_dpu_list", return_value=["dpu1", "dpu2"]) + @patch("os.path.isfile", return_value=True) @patch("process_reboot_cause.get_sorted_reboot_cause_files") @patch("process_reboot_cause.os.listdir", return_value=["2024_12_13_01_12_36_reboot_cause.txt", "2024_12_14_01_11_46_reboot_cause.txt"]) @patch("process_reboot_cause.swsscommon.SonicV2Connector") - def test_update_dpu_reboot_cause_to_chassis_state_db_update(self, mock_connector, mock_listdir, mock_get_sorted_files, mock_get_dpu_list, mock_open): + def test_update_dpu_reboot_cause_to_chassis_state_db_update(self, mock_connector, mock_listdir, mock_get_sorted_files, mock_isfile, mock_get_dpu_list, mock_open): # Setup mocks mock_get_sorted_files.return_value = ["/mock/dpu_history/2024_12_13_01_12_36_reboot_cause.txt"] @@ -110,8 +111,5 @@ def test_update_dpu_reboot_cause_to_chassis_state_db_update(self, mock_connector mock_db = MagicMock() mock_connector.return_value = mock_db - # Simulate a valid file (matching DPU0) - file_path = "/mock/dpu_history/2024_12_13_01_12_36_reboot_cause.txt" - # Call the function that reads the file and updates the DB process_reboot_cause.update_dpu_reboot_cause_to_chassis_state_db()