Skip to content

Commit

Permalink
Add notify system ready unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com>
  • Loading branch information
fastiuk committed May 20, 2024
1 parent b08e588 commit c95de0e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c95de0e

Please sign in to comment.