Skip to content

Commit 529f01c

Browse files
committed
Add unit test cases
Signed-off-by: Kebo Liu <[email protected]>
1 parent 22fe390 commit 529f01c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

sonic-xcvrd/tests/test_xcvrd.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,14 @@ def test_init_port_sfp_status_tbl(self):
551551
task = SfpStateUpdateTask(DEFAULT_NAMESPACE, port_mapping, stop_event, sfp_error_event)
552552
task._init_port_sfp_status_tbl(port_mapping, xcvr_table_helper, stop_event)
553553

554-
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=('/invalid/path', None)))
554+
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=('/invalid/path', '/invalid/path')))
555555
def test_load_media_settings_missing_file(self):
556556
assert media_settings_parser.load_media_settings() == {}
557557

558+
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=('/invalid/path', '/invalid/path')))
559+
def test_load_optical_si_settings_missing_file(self):
560+
assert optics_si_parser.load_optics_si_settings() == {}
561+
558562
@patch('xcvrd.xcvrd.platform_chassis')
559563
@patch('xcvrd.xcvrd.is_cmis_api')
560564
def test_get_media_settings_key(self, mock_is_cmis_api, mock_chassis):
@@ -2041,6 +2045,21 @@ def test_DaemonXcvrd_init_deinit_fastboot_enabled(self):
20412045
xcvrd.init()
20422046
xcvrd.deinit()
20432047

2048+
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=(test_path, '/invalid/path')))
2049+
def test_load_optical_si_file_from_platform_folder(self):
2050+
assert optics_si_parser.load_optics_si_settings() != {}
2051+
2052+
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=('/invalid/path', test_path)))
2053+
def test_load_optical_si_file_from_hwsku_folder(self):
2054+
assert optics_si_parser.load_optics_si_settings() != {}
2055+
2056+
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=(test_path, '/invalid/path')))
2057+
def test_load_media_settings_file_from_platform_folder(self):
2058+
assert media_settings_parser.load_media_settings() != {}
2059+
2060+
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=('/invalid/path', test_path)))
2061+
def test_load_media_settings_file_from_hwsku_folder(self):
2062+
assert media_settings_parser.load_media_settings() != {}
20442063

20452064
def wait_until(total_wait_time, interval, call_back, *args, **kwargs):
20462065
wait_time = 0

0 commit comments

Comments
 (0)