@@ -586,7 +586,7 @@ def mock_get_transceiver_dom_flags(physical_port):
586
586
dom_tbl = Table ("STATE_DB" , TRANSCEIVER_DOM_FLAG_TABLE )
587
587
dom_db_utils .xcvr_table_helper .get_dom_flag_tbl = MagicMock (return_value = dom_tbl )
588
588
dom_db_utils .dom_utils .get_transceiver_dom_flags = MagicMock (return_value = None )
589
- dom_db_utils .update_flag_metadata_tables = MagicMock ()
589
+ dom_db_utils ._update_flag_metadata_tables = MagicMock ()
590
590
assert dom_tbl .get_size () == 0
591
591
592
592
# Ensure table is empty asic_index is None
@@ -618,17 +618,17 @@ def mock_get_transceiver_dom_flags(physical_port):
618
618
dom_db_utils .dom_utils .get_transceiver_dom_flags = MagicMock (side_effect = mock_get_transceiver_dom_flags )
619
619
dom_db_utils .post_port_dom_flags_to_db (logical_port_name , db_cache = db_cache )
620
620
assert dom_tbl .get_size_for_key (logical_port_name ) == 21
621
- assert dom_db_utils .update_flag_metadata_tables .call_count == 1
621
+ assert dom_db_utils ._update_flag_metadata_tables .call_count == 1
622
622
623
623
# Reset the mock to clear the call count
624
- dom_db_utils .update_flag_metadata_tables .reset_mock ()
624
+ dom_db_utils ._update_flag_metadata_tables .reset_mock ()
625
625
626
626
# Ensure db_cache is populated correctly
627
627
assert db_cache .get (0 ) is not None
628
628
dom_db_utils .dom_utils .get_transceiver_dom_flags = MagicMock (return_value = None )
629
629
dom_db_utils .post_port_dom_flags_to_db (logical_port_name , db_cache = db_cache )
630
630
assert dom_tbl .get_size_for_key (logical_port_name ) == 21
631
- assert dom_db_utils .update_flag_metadata_tables .call_count == 0
631
+ assert dom_db_utils ._update_flag_metadata_tables .call_count == 0
632
632
633
633
@pytest .mark .parametrize ("flag_value_table, flag_value_table_found, current_value, expected_change_count, expected_set_time, expected_clear_time" , [
634
634
(None , False , 'N/A' , None , None , None ),
@@ -665,7 +665,7 @@ def field_value_pairs_to_dict(fvp):
665
665
stop_event = threading .Event ()
666
666
db_utils = DBUtils (mock_sfp_obj_dict , port_mapping , stop_event , mock_logger )
667
667
# Call the function
668
- db_utils .update_flag_metadata_tables (logical_port_name , mock_curr_flag_dict ,
668
+ db_utils ._update_flag_metadata_tables (logical_port_name , mock_curr_flag_dict ,
669
669
flag_values_dict_update_time , flag_value_table ,
670
670
flag_change_count_table , flag_last_set_time_table ,
671
671
flag_last_clear_time_table , table_name_for_logging )
@@ -966,7 +966,7 @@ def mock_get_transceiver_status(physical_port):
966
966
status_db_utils .post_port_transceiver_hw_status_to_db (logical_port_name , db_cache = db_cache )
967
967
assert status_tbl .get_size_for_key (logical_port_name ) == 12
968
968
969
- def testpost_port_transceiver_hw_status_flags_to_db (self ):
969
+ def test_post_port_transceiver_hw_status_flags_to_db (self ):
970
970
def mock_get_transceiver_status_flags (physical_port ):
971
971
return {
972
972
"datapath_firmware_fault" : "False" ,
@@ -996,7 +996,7 @@ def mock_get_transceiver_status_flags(physical_port):
996
996
status_flag_tbl = Table ("STATE_DB" , TRANSCEIVER_STATUS_FLAG_TABLE )
997
997
status_db_utils .xcvr_table_helper .get_status_flag_tbl = MagicMock (return_value = status_flag_tbl )
998
998
status_db_utils .status_utils .get_transceiver_status_flags = MagicMock (return_value = None )
999
- status_db_utils .update_flag_metadata_tables = MagicMock ()
999
+ status_db_utils ._update_flag_metadata_tables = MagicMock ()
1000
1000
assert status_flag_tbl .get_size () == 0
1001
1001
1002
1002
# Ensure table is empty asic_index is None
@@ -1028,17 +1028,17 @@ def mock_get_transceiver_status_flags(physical_port):
1028
1028
status_db_utils .status_utils .get_transceiver_status_flags = MagicMock (side_effect = mock_get_transceiver_status_flags )
1029
1029
status_db_utils .post_port_transceiver_hw_status_flags_to_db (logical_port_name , db_cache = db_cache )
1030
1030
assert status_flag_tbl .get_size_for_key (logical_port_name ) == 12
1031
- assert status_db_utils .update_flag_metadata_tables .call_count == 1
1031
+ assert status_db_utils ._update_flag_metadata_tables .call_count == 1
1032
1032
1033
1033
# Reset the mock to clear the call count
1034
- status_db_utils .update_flag_metadata_tables .reset_mock ()
1034
+ status_db_utils ._update_flag_metadata_tables .reset_mock ()
1035
1035
1036
1036
# Ensure db_cache is populated correctly
1037
1037
assert db_cache .get (0 ) is not None
1038
1038
status_db_utils .status_utils .get_transceiver_status_flags = MagicMock (return_value = None )
1039
1039
status_db_utils .post_port_transceiver_hw_status_flags_to_db (logical_port_name , db_cache = db_cache )
1040
1040
assert status_flag_tbl .get_size_for_key (logical_port_name ) == 12
1041
- assert status_db_utils .update_flag_metadata_tables .call_count == 0
1041
+ assert status_db_utils ._update_flag_metadata_tables .call_count == 0
1042
1042
1043
1043
@patch ('xcvrd.xcvrd_utilities.port_event_helper.PortMapping.logical_port_name_to_physical_port_list' , MagicMock (return_value = [0 ]))
1044
1044
@patch ('xcvrd.xcvrd._wrapper_get_presence' , MagicMock (return_value = True ))
@@ -3301,11 +3301,16 @@ def test_beautify_dom_info_dict(self):
3301
3301
port_mapping = PortMapping ()
3302
3302
xcvr_table_helper = XcvrTableHelper (DEFAULT_NAMESPACE )
3303
3303
stop_event = threading .Event ()
3304
- dom_db_utils = DOMDBUtils (mock_sfp_obj_dict , port_mapping , xcvr_table_helper , stop_event , helper_logger )
3304
+ mock_logger = MagicMock ()
3305
+ dom_db_utils = DOMDBUtils (mock_sfp_obj_dict , port_mapping , xcvr_table_helper , stop_event , mock_logger )
3305
3306
3306
3307
dom_db_utils ._beautify_dom_info_dict (dom_info_dict )
3307
3308
assert dom_info_dict == expected_dom_info_dict
3308
3309
3310
+ # Ensure that the method handles None input gracefully and logs a warning
3311
+ dom_db_utils ._beautify_dom_info_dict (None )
3312
+ mock_logger .log_warning .assert_called_once_with ("DOM info dict is None while beautifying" )
3313
+
3309
3314
def test_beautify_info_dict (self ):
3310
3315
dom_info_dict = {
3311
3316
'eSNR' : 1.1 ,
0 commit comments