Skip to content

Commit

Permalink
Add UT coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jemifdo committed Jul 30, 2024
1 parent 094e843 commit 072396b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,11 +998,16 @@ def test_CmisManagerTask_update_port_transceiver_status_table_sw_cmis_state(self
task.update_port_transceiver_status_table_sw_cmis_state("Ethernet0", CMIS_STATE_INSERTED)
assert mock_get_status_tbl.set.call_count == 1

@patch('xcvrd.xcvrd.xcvr_table_helper')
@patch('xcvrd.xcvrd._wrapper_get_sfp_type', MagicMock(return_value='QSFP_DD'))
def test_CmisManagerTask_handle_port_change_event(self):
def test_CmisManagerTask_handle_port_change_event(self, mock_table_helper):
port_mapping = PortMapping()
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
status_tbl = MagicMock()
status_tbl.delete = MagicMock()
mock_table_helper.get_status_tbl = MagicMock(return_value=status_tbl)
task.xcvr_table_helper.get_status_tbl = mock_table_helper.get_status_tbl

assert not task.isPortConfigDone
port_change_event = PortChangeEvent('PortConfigDone', -1, 0, PortChangeEvent.PORT_SET)
Expand All @@ -1017,10 +1022,6 @@ def test_CmisManagerTask_handle_port_change_event(self):
task.on_port_update_event(port_change_event)
assert len(task.port_dict) == 0

port_change_event = PortChangeEvent('Ethernet0', 1, 0, PortChangeEvent.PORT_DEL)
task.on_port_update_event(port_change_event)
assert len(task.port_dict) == 0

port_change_event = PortChangeEvent('Ethernet0', 1, 0, PortChangeEvent.PORT_SET)
task.on_port_update_event(port_change_event)
assert len(task.port_dict) == 0
Expand All @@ -1029,6 +1030,10 @@ def test_CmisManagerTask_handle_port_change_event(self):
task.on_port_update_event(port_change_event)
assert len(task.port_dict) == 1

port_change_event = PortChangeEvent('Ethernet0', 1, 0, PortChangeEvent.PORT_DEL, {'index':1})
task.on_port_update_event(port_change_event)
assert len(task.port_dict) == 0


@patch('xcvrd.xcvrd.XcvrTableHelper')
def test_CmisManagerTask_get_configured_freq(self, mock_table_helper):
Expand Down

0 comments on commit 072396b

Please sign in to comment.