Skip to content

Commit 3e432e7

Browse files
ashwnsriAshwin Srinivasan
andauthored
[Y-Cable] Increased unit test coverage of y_cable_helper.py (sonic-net#229)
Added unit tests for the following methods: y_cable_wrapper_get_transceiver_info y_cable_wrapper_get_presence y_cable_toggle_mux_torA y_cable_toggle_mux_torB format_mapping_identifier update_appdb_port_mux_cable_response_table update_table_mux_status_for_response_tbl update_tor_active_side read_y_cable_and_update_statedb_port_tbl delete_port_from_y_cable_table create_tables_and_insert_mux_unknown_entries check_identifier_presencead_update_mux_table_entry init_ports_status_for_y_cable change_ports_status_for_y_cable_change_event delete_ports_status_for_y_cable get_firmware_dict get_muxcable_info get_muxcable_static_info post_mux_info_to_db task_download_firmware_worker Motivation and Context The motivation for these changes stems from needing to increase the unit test coverage of the y_cable_helper methods to above 50%. How Has This Been Tested? This was tested by building and running the new unit tests and verifying that they contribute to and increase the code coverage as reflected in the xcvrd_xcvrd_utilities_y_cable_helper_py.html page. Co-authored-by: Ashwin Srinivasan <[email protected]>
1 parent 7c363f5 commit 3e432e7

File tree

4 files changed

+2052
-179
lines changed

4 files changed

+2052
-179
lines changed

sonic-xcvrd/tests/mock_swsscommon.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ class Table:
66
def __init__(self, db, table_name):
77
self.table_name = table_name
88
self.mock_dict = {}
9+
self.mock_keys = []
910

1011
def _del(self, key):
1112
if key in self.mock_dict:
1213
del self.mock_dict[key]
14+
self.mock_keys.remove(key)
1315
pass
1416

1517
def set(self, key, fvs):
1618
self.mock_dict[key] = fvs
19+
self.mock_keys.append(key)
1720
pass
1821

1922
def get(self, key):
@@ -23,6 +26,9 @@ def get(self, key):
2326

2427
def get_size(self):
2528
return (len(self.mock_dict))
29+
30+
def getKeys(self):
31+
return self.mock_keys
2632

2733

2834
class FieldValuePairs:

0 commit comments

Comments
 (0)