diff --git a/tests/process-reboot-cause_test.py b/tests/process-reboot-cause_test.py index 063984d8..90b5c9c3 100644 --- a/tests/process-reboot-cause_test.py +++ b/tests/process-reboot-cause_test.py @@ -71,7 +71,8 @@ def test_invalid_json(self, mock_geteuid, mock_stdout, mock_is_smartswitch, mock @patch("process_reboot_cause.swsscommon.SonicV2Connector") @patch("process_reboot_cause.device_info.get_dpu_list", return_value=["dpu1", "dpu2"]) - def test_update_dpu_reboot_cause_to_chassis_state_db(self, mock_get_dpu_list, mock_connector): + @patch("process_reboot_cause.os.listdir", return_value=["reboot-cause-file-1", "reboot-cause-file-2"]) + def test_update_dpu_reboot_cause_to_chassis_state_db(self, mock_listdir, mock_get_dpu_list, mock_connector): # Mock DB mock_db = MagicMock() mock_connector.return_value = mock_db @@ -80,9 +81,10 @@ def test_update_dpu_reboot_cause_to_chassis_state_db(self, mock_get_dpu_list, mo process_reboot_cause.update_dpu_reboot_cause_to_chassis_state_db() # Verify DB interactions for each DPU - mock_db.set.assert_any_call(mock_db.CHASSIS_STATE_DB, "REBOOT_CAUSE|DPU1", "cause", "PowerLoss") - mock_db.set.assert_any_call(mock_db.CHASSIS_STATE_DB, "REBOOT_CAUSE|DPU1", "time", "2024-12-10") + mock_db.set.assert_any_call(mock_db.CHASSIS_STATE_DB, 'REBOOT_CAUSE|DPU1', 'cause', 'PowerLoss') + mock_db.set.assert_any_call(mock_db.CHASSIS_STATE_DB, 'REBOOT_CAUSE|DPU2', 'cause', 'PowerLoss') + ''' @patch("process_reboot_cause.device_info.get_dpu_list", return_value=[]) def test_invalid_dpu_list(self, mock_get_dpu_list): # Call the function with an empty DPU list @@ -90,3 +92,4 @@ def test_invalid_dpu_list(self, mock_get_dpu_list): # Ensure no DB interactions occur when DPU list is empty mock_get_dpu_list.assert_called_once() + '''