From c95de0e6c2efecf3fb2b9b0a574ab8ef5c43c315 Mon Sep 17 00:00:00 2001 From: Yevhen Fastiuk Date: Mon, 20 May 2024 17:32:07 +0300 Subject: [PATCH] Add notify system ready unit tests Signed-off-by: Yevhen Fastiuk --- sonic-xcvrd/tests/test_xcvrd.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sonic-xcvrd/tests/test_xcvrd.py b/sonic-xcvrd/tests/test_xcvrd.py index f28052642..5a37e40fe 100644 --- a/sonic-xcvrd/tests/test_xcvrd.py +++ b/sonic-xcvrd/tests/test_xcvrd.py @@ -318,6 +318,23 @@ def test_is_cmis_api(self, mock_class, expected_return_value): mock_xcvr_api.__class__ = mock_class assert is_cmis_api(mock_xcvr_api) == expected_return_value + @patch('swsscommon.swsscommon.SonicV2Connector') + def test_notify_system_ready(self, mock_dbconn): + mock_db = MagicMock() + mock_db.connect = MagicMock() + mock_db.delete = MagicMock() + mock_db.hmset = MagicMock() + mock_dbconn.return_value = mock_db + + # Case 1: Report ready status + notify_system_ready() + mock_db.hmset.assert_called_once() + + # Case 2: Should not report status again + mock_db.hmset.reset_mock() + notify_system_ready() + mock_db.hmset.assert_not_called() + @patch('xcvrd.xcvrd._wrapper_get_sfp_type') @patch('xcvrd.xcvrd_utilities.port_event_helper.PortMapping.logical_port_name_to_physical_port_list', MagicMock(return_value=[0])) @patch('xcvrd.xcvrd._wrapper_get_presence', MagicMock(return_value=True))