Skip to content

Commit

Permalink
Iproving coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshraghupathy committed Dec 13, 2024
1 parent 1a55a59 commit 74c38ae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/process-reboot-cause_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -80,13 +81,15 @@ 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
process_reboot_cause.update_dpu_reboot_cause_to_chassis_state_db()
# Ensure no DB interactions occur when DPU list is empty
mock_get_dpu_list.assert_called_once()
'''

0 comments on commit 74c38ae

Please sign in to comment.