Skip to content

Commit

Permalink
Add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
yejianquan committed Dec 16, 2024
1 parent c68978c commit 95e1901
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_rfc2737.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import sys
from unittest import TestCase
from sonic_ax_impl.mibs.ietf.rfc2737 import PhysicalTableMIBUpdater


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

modules_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(modules_path, 'src'))


class TestPhysicalSensorTableMIBUpdater(TestCase):

@mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.PsuCacheUpdater.reinit_data', side_effect=Exception('mocked error'))
def test_PhysicalSensorTableMIBUpdater_transceiver_info_key_missing(self):
updater = PhysicalTableMIBUpdater()

with mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.ThermalCacheUpdater.reinit_data') as mocked_reinit_data:
updater.reinit_data()

# check warning
mocked_reinit_data.assert_called()

0 comments on commit 95e1901

Please sign in to comment.