Skip to content

Commit 0454141

Browse files
committed
adding tests for redis pipeline flush test coverage
1 parent 671d472 commit 0454141

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sonic-psud/tests/test_DaemonPsud.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ def test_run(self):
107107
daemon_psud.run()
108108
assert daemon_psud.first_run is False
109109

110+
# Test Redis pipeline flush exception scenario
111+
daemon_psud.statedb_redisPipeline.flush = mock.MagicMock(side_effect=Exception("Flush error"))
112+
daemon_psud.log_error = mock.MagicMock()
113+
114+
result = daemon_psud.run()
115+
assert result is True
116+
assert daemon_psud.first_run is False
117+
daemon_psud.log_error.assert_called_once()
118+
assert "Exception occurred while flushing Redis pipeline" in daemon_psud.log_error.call_args[0][0]
119+
110120
def test_update_psu_data(self):
111121
mock_psu1 = MockPsu("PSU 1", 0, True, True)
112122
mock_psu2 = MockPsu("PSU 2", 1, True, True)

0 commit comments

Comments
 (0)