Skip to content

Commit

Permalink
Add unit-test
Browse files Browse the repository at this point in the history
Signed-off-by: Suvarna Meenakshi <[email protected]>
(cherry picked from commit 00ea285044490f272d2bdd698336ae76a6b1c38f)
  • Loading branch information
SuvarnaMeenakshi committed Jul 12, 2024
1 parent b89ec3f commit 4cc003c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/namespace/test_pfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import sys
import importlib

if sys.version_info.major == 3:
from unittest import mock
else:
import mock

# noinspection PyUnresolvedReferences
import tests.mock_tables.dbconnector

Expand Down Expand Up @@ -265,6 +270,18 @@ def test_getPfcSubtree(self):
self.assertEqual(str(value0.name), str(expected_oid))
self.assertEqual(value0.data, 209347219842134092490 % pow(2, 64)) # Test integer truncation

def test_no_interfaces(self):
# Test the scenario where there are no interfaces
# like the case of Packet-chassis supervisor
ciscoPfcExtMIB.cpfcIfTable.pfc_updater.if_range = []
importlib.reload(ciscoPfcExtMIB)
oid = ObjectIdentifier(32, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1))
sub_id = ()
with mock.patch('sonic_ax_impl.mibs.logger.error') as mock_logger:
get_pdu = ciscoPfcExtMIB.cpfcIfTable.pfc_updater.get_next(sub_id)
self.assertEqual(get_pdu, None)
mock_logger.assert_not_called()

@classmethod
def tearDownClass(cls):
tests.mock_tables.dbconnector.clean_up_config()

0 comments on commit 4cc003c

Please sign in to comment.