Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _get_vdm_key_to_db_prefix_map_by_observable_type(self, observable_type):

@staticmethod
def _strip_str(val):
return val.rstrip() if isinstance(val, str) else val
return val.replace('\x00', '').rstrip() if isinstance(val, str) else val
Comment thread
wenyiz2021 marked this conversation as resolved.

def _update_vdm_dict(self, dict_to_update, new_key, vdm_raw_dict, vdm_observable_type, vdm_subtype_index, lane):
"""
Expand Down
11 changes: 11 additions & 0 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ def setup_method(self, method):
self.api._cdb_fw_hdlr = None
self.api._init_cdb_fw_handler = False

@pytest.mark.parametrize("mock_response, expected", [
("VENDOR_NAME", "VENDOR_NAME"),
("A\x00\x00\x00\x00\x00Networks\n", "ANetworks"),
])
def test_get_manufacturer(self, mock_response, expected):
self.api.xcvr_eeprom.read = MagicMock()
self.api.xcvr_eeprom.read.return_value = mock_response
self.clear_cache('get_manufacturer')
result = self.api.get_manufacturer()
assert result == expected

@pytest.mark.parametrize("mock_response, expected", [
("1234567890", "1234567890"),
("ABCD", "ABCD")
Expand Down
Loading