From e955e584ebf1b2fc9d9eb640b24aad4819612439 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Mon, 9 Dec 2024 17:23:22 +0800 Subject: [PATCH] get_error_description should return 'OK' instead of None when there is no error (#518) - 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. Signed-off-by: Kebo Liu --- 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):