Skip to content

Commit

Permalink
[Y-Cable] Increased unit test coverage of y_cable_helper.py (#229)
Browse files Browse the repository at this point in the history
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 <ashwin.srinivasan@microsoft.com>
  • Loading branch information
assrinivasan and assrinivasan authored Dec 24, 2021
1 parent 7c363f5 commit 3e432e7
Show file tree
Hide file tree
Showing 4 changed files with 2,052 additions and 179 deletions.
6 changes: 6 additions & 0 deletions sonic-xcvrd/tests/mock_swsscommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ class Table:
def __init__(self, db, table_name):
self.table_name = table_name
self.mock_dict = {}
self.mock_keys = []

def _del(self, key):
if key in self.mock_dict:
del self.mock_dict[key]
self.mock_keys.remove(key)
pass

def set(self, key, fvs):
self.mock_dict[key] = fvs
self.mock_keys.append(key)
pass

def get(self, key):
Expand All @@ -23,6 +26,9 @@ def get(self, key):

def get_size(self):
return (len(self.mock_dict))

def getKeys(self):
return self.mock_keys


class FieldValuePairs:
Expand Down
Loading

0 comments on commit 3e432e7

Please sign in to comment.