From 38a7a65bd5c64662a5d7c9aa4bdcf9920a0c5765 Mon Sep 17 00:00:00 2001 From: mihirpat1 <112018033+mihirpat1@users.noreply.github.com> Date: Wed, 25 Jan 2023 09:49:05 -0800 Subject: [PATCH] Change get_tx_bias return type to list (#342) * Change get_tx_bias return type to list Signed-off-by: Mihir Patel --- sonic_platform_base/sonic_xcvr/api/public/cmis.py | 4 ++-- tests/sonic_xcvr/test_cmis.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/sonic_platform_base/sonic_xcvr/api/public/cmis.py b/sonic_platform_base/sonic_xcvr/api/public/cmis.py index c667c9b61cb0..1185440564cb 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmis.py @@ -207,7 +207,7 @@ def get_transceiver_bulk_status(self): for i in range(1, self.NUM_CHANNELS + 1): bulk_status["tx%ddisable" % i] = tx_disable[i-1] if self.get_tx_disable_support() else 'N/A' - bulk_status["tx%dbias" % i] = tx_bias['LaserBiasTx%dField' % i] if self.get_tx_bias_support() else 'N/A' + bulk_status["tx%dbias" % i] = tx_bias[i - 1] bulk_status["rx%dpower" % i] = float("{:.3f}".format(self.mw_to_dbm(rx_power[i - 1]))) if self.get_rx_power_support() else 'N/A' bulk_status["tx%dpower" % i] = float("{:.3f}".format(self.mw_to_dbm(tx_power[i - 1]))) if self.get_tx_power_support() else 'N/A' @@ -495,7 +495,7 @@ def get_tx_bias(self): tx_bias = self.xcvr_eeprom.read(consts.TX_BIAS_FIELD) for key, value in tx_bias.items(): tx_bias[key] *= scale - return tx_bias + return [tx_bias['LaserBiasTx%dField' % i] for i in range(1, self.NUM_CHANNELS + 1)] def get_tx_power(self): ''' diff --git a/tests/sonic_xcvr/test_cmis.py b/tests/sonic_xcvr/test_cmis.py index 7822e9ee2878..4380f0852f31 100644 --- a/tests/sonic_xcvr/test_cmis.py +++ b/tests/sonic_xcvr/test_cmis.py @@ -358,9 +358,11 @@ def test_get_tx_bias_support(self, mock_response, expected): assert result == expected @pytest.mark.parametrize("mock_response, expected", [ - ([True, 2, {'TxBias1': 2}], {'TxBias1': 8}), - ([True, 3, {'TxBias1': 2}], {'TxBias1': 2}), - ([False, 0, {'TxBias1': 0}], ['N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']), + ([True, 2, {'LaserBiasTx1Field': 2, 'LaserBiasTx2Field': 2, 'LaserBiasTx3Field': 2, 'LaserBiasTx4Field': 2, 'LaserBiasTx5Field': 2, 'LaserBiasTx6Field': 2, 'LaserBiasTx7Field': 2, 'LaserBiasTx8Field': 2}], + [8, 8, 8, 8, 8, 8, 8, 8]), + ([True, 3, {'LaserBiasTx1Field': 2, 'LaserBiasTx2Field': 2, 'LaserBiasTx3Field': 2, 'LaserBiasTx4Field': 2, 'LaserBiasTx5Field': 2, 'LaserBiasTx6Field': 2, 'LaserBiasTx7Field': 2, 'LaserBiasTx8Field': 2}], + [2, 2, 2, 2, 2, 2, 2, 2]), + ([False, 0, {'LaserBiasTx1Field': 0}], ['N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']), ([None, 0, None], None) ]) def test_get_tx_bias(self, mock_response, expected): @@ -1221,10 +1223,7 @@ def test_get_transceiver_info(self, mock_response, expected): 0, 50, 3.3, - {'LaserBiasTx1Field': 70, 'LaserBiasTx2Field': 70, - 'LaserBiasTx3Field': 70, 'LaserBiasTx4Field': 70, - 'LaserBiasTx5Field': 70, 'LaserBiasTx6Field': 70, - 'LaserBiasTx7Field': 70, 'LaserBiasTx8Field': 70}, + [70, 70, 70, 70, 70, 70, 70, 70], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], True, True, True, True, True, True,