|
17 | 17 | daemon_base.db_connect = MagicMock()
|
18 | 18 | swsscommon.Table = MagicMock()
|
19 | 19 | swsscommon.ProducerStateTable = MagicMock()
|
| 20 | +swsscommon.SubscriberStateTable = MagicMock() |
| 21 | +swsscommon.SonicDBConfig = MagicMock() |
| 22 | +#swsscommon.Select = MagicMock() |
| 23 | + |
20 | 24 | sys.modules['sonic_y_cable'] = MagicMock()
|
21 | 25 | sys.modules['sonic_y_cable.y_cable'] = MagicMock()
|
22 | 26 |
|
@@ -217,7 +221,7 @@ def test_init_port_sfp_status_tbl(self):
|
217 | 221 |
|
218 | 222 | @patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_platform_sfputil', MagicMock(return_value=[0]))
|
219 | 223 | @patch('xcvrd.xcvrd_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
|
220 |
| - @patch('xcvrd.xcvrd_utilities.y_cable_helper._wrapper_get_presence', MagicMock(return_value=True)) |
| 224 | + @patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_wrapper_get_presence', MagicMock(return_value=True)) |
221 | 225 | @patch('xcvrd.xcvrd_utilities.y_cable_helper.get_muxcable_info', MagicMock(return_value={'tor_active': 'self',
|
222 | 226 | 'mux_direction': 'self',
|
223 | 227 | 'manual_switch_count': '7',
|
@@ -254,9 +258,10 @@ def test_post_port_mux_info_to_db(self):
|
254 | 258 | rc = post_port_mux_info_to_db(logical_port_name, mux_tbl)
|
255 | 259 | assert(rc != -1)
|
256 | 260 |
|
| 261 | + |
257 | 262 | @patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_platform_sfputil', MagicMock(return_value=[0]))
|
258 | 263 | @patch('xcvrd.xcvrd_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
|
259 |
| - @patch('xcvrd.xcvrd_utilities.y_cable_helper._wrapper_get_presence', MagicMock(return_value=True)) |
| 264 | + @patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_wrapper_get_presence', MagicMock(return_value=True)) |
260 | 265 | @patch('xcvrd.xcvrd_utilities.y_cable_helper.get_muxcable_static_info', MagicMock(return_value={'read_side': 'self',
|
261 | 266 | 'nic_lane1_precursor1': '1',
|
262 | 267 | 'nic_lane1_precursor2': '-7',
|
@@ -294,6 +299,65 @@ def test_post_port_mux_static_info_to_db(self):
|
294 | 299 | rc = post_port_mux_static_info_to_db(logical_port_name, mux_tbl)
|
295 | 300 | assert(rc != -1)
|
296 | 301 |
|
| 302 | + def test_y_cable_helper_format_mapping_identifier1(self): |
| 303 | + rc = format_mapping_identifier("ABC ") |
| 304 | + assert(rc == "abc") |
| 305 | + |
| 306 | + def test_y_cable_wrapper_get_transceiver_info(self): |
| 307 | + with patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_platform_sfputil') as patched_util: |
| 308 | + patched_util.get_transceiver_info_dict.return_value = {'manufacturer': 'Microsoft', |
| 309 | + 'model': 'model1'} |
| 310 | + |
| 311 | + transceiver_dict = y_cable_wrapper_get_transceiver_info(1) |
| 312 | + vendor = transceiver_dict.get('manufacturer') |
| 313 | + model = transceiver_dict.get('model') |
| 314 | + |
| 315 | + assert(vendor == "Microsoft") |
| 316 | + assert(model == "model1") |
| 317 | + |
| 318 | + def test_y_cable_wrapper_get_presence(self): |
| 319 | + with patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_platform_sfputil') as patched_util: |
| 320 | + patched_util.get_presence.return_value = True |
| 321 | + |
| 322 | + presence = y_cable_wrapper_get_presence(1) |
| 323 | + |
| 324 | + assert(presence == True) |
| 325 | + |
| 326 | + @patch('xcvrd.xcvrd_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0])) |
| 327 | + @patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_wrapper_get_presence', MagicMock(return_value=True)) |
| 328 | + def test_get_ycable_physical_port_from_logical_port(self): |
| 329 | + |
| 330 | + instance = get_ycable_physical_port_from_logical_port("Ethernet0") |
| 331 | + |
| 332 | + assert(instance == 0) |
| 333 | + |
| 334 | + @patch('xcvrd.xcvrd_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0])) |
| 335 | + @patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_wrapper_get_presence', MagicMock(return_value=True)) |
| 336 | + def test_get_ycable_port_instance_from_logical_port(self): |
| 337 | + |
| 338 | + with patch('xcvrd.xcvrd_utilities.y_cable_helper.y_cable_port_instances') as patched_util: |
| 339 | + patched_util.get.return_value = 0 |
| 340 | + instance = get_ycable_port_instance_from_logical_port("Ethernet0") |
| 341 | + |
| 342 | + assert(instance == 0) |
| 343 | + |
| 344 | + def test_set_show_firmware_fields(self): |
| 345 | + |
| 346 | + mux_info_dict = {} |
| 347 | + xcvrd_show_fw_res_tbl = Table("STATE_DB", "XCVRD_SHOW_FW_RES") |
| 348 | + mux_info_dict['version_self_active'] = '0.8' |
| 349 | + mux_info_dict['version_self_inactive'] = '0.7' |
| 350 | + mux_info_dict['version_self_next'] = '0.7' |
| 351 | + mux_info_dict['version_peer_active'] = '0.8' |
| 352 | + mux_info_dict['version_peer_inactive'] = '0.7' |
| 353 | + mux_info_dict['version_peer_next'] = '0.7' |
| 354 | + mux_info_dict['version_nic_active'] = '0.8' |
| 355 | + mux_info_dict['version_nic_inactive'] = '0.7' |
| 356 | + mux_info_dict['version_nic_next'] = '0.7' |
| 357 | + rc = set_show_firmware_fields("Ethernet0", mux_info_dict, xcvrd_show_fw_res_tbl) |
| 358 | + |
| 359 | + assert(rc == 0) |
| 360 | + |
297 | 361 | def test_get_media_settings_key(self):
|
298 | 362 | xcvr_info_dict = {
|
299 | 363 | 0: {
|
|
0 commit comments