diff --git a/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py b/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py index 668389e14..cedc983b2 100644 --- a/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py +++ b/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py @@ -167,7 +167,10 @@ def set_lpmode(self, lpmode): return api.set_lpmode(lpmode) if api is not None else None def set_optoe_write_max(self, write_max): - sys_path = self.get_eeprom_path() + try: + sys_path = self.get_eeprom_path() + except NotImplementedError: + return sys_path = sys_path.replace("eeprom", "write_max") try: with open(sys_path, mode='w') as f: diff --git a/tests/sonic_xcvr/test_sfp_optoe_base.py b/tests/sonic_xcvr/test_sfp_optoe_base.py new file mode 100644 index 000000000..4fb89255b --- /dev/null +++ b/tests/sonic_xcvr/test_sfp_optoe_base.py @@ -0,0 +1,10 @@ +from unittest.mock import patch +from mock import MagicMock +import pytest +from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + +class TestSfpOptoeBase(object): + optoebase = SfpOptoeBase() + + def test_set_optoe_write_max_with_exception(self): + self.optoebase.set_optoe_write_max(1)