From 89e8827c8ffe10f60cd11b651b181e68b8e23b03 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Tue, 14 Jan 2025 04:02:17 +0800 Subject: [PATCH] [CMIS]The "get_error_description" function should return 'OK' instead of None when there are no errors. (#528) #### Description The "get_error_description" function should return 'OK' instead of 'None' when there are no errors. #### Motivation and Context When there are no errors on the cable, get_error_description currently returns 'None'. In this case, we should return 'OK' so that the CLI (show interface transceiver error-description) provides a proper output. #### How Has This Been Tested? Call this API directly on different cables with different error statuses. #### Additional Information (Optional) --- sonic_platform_base/sonic_xcvr/api/public/cmis.py | 2 +- tests/sonic_xcvr/test_cmis.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sonic_platform_base/sonic_xcvr/api/public/cmis.py b/sonic_platform_base/sonic_xcvr/api/public/cmis.py index f716db1f1..a96e76aef 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmis.py @@ -3152,6 +3152,6 @@ def get_error_description(self): if state != CmisCodes.MODULE_STATE[3]: return state - return None + return 'OK' # TODO: other XcvrApi methods diff --git a/tests/sonic_xcvr/test_cmis.py b/tests/sonic_xcvr/test_cmis.py index 5e94b3d9e..5738fc71b 100644 --- a/tests/sonic_xcvr/test_cmis.py +++ b/tests/sonic_xcvr/test_cmis.py @@ -3066,7 +3066,7 @@ def test_get_error_description(self): self.api.xcvr_eeprom.read.return_value = 0x10 result = self.api.get_error_description() - assert result is None + assert result is 'OK' def test_random_read_fail(self): def mock_read_raw(offset, size):