diff --git a/tests/test_rfc2737.py b/tests/test_rfc2737.py index 72a40388c..9dbc12f51 100644 --- a/tests/test_rfc2737.py +++ b/tests/test_rfc2737.py @@ -1,6 +1,8 @@ import os import sys from unittest import TestCase + +import pytest from sonic_ax_impl.mibs.ietf.rfc2737 import PhysicalTableMIBUpdater @@ -19,8 +21,16 @@ class TestPhysicalTableMIBUpdater(TestCase): def test_PhysicalTableMIBUpdater_exception_in_reinit_data_wont_block_reinit_iteration(self, mock_psu_reinit_data): updater = PhysicalTableMIBUpdater() - with mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.ThermalCacheUpdater.reinit_data') as mocked_reinit_data: + with (pytest.raises(Exception) as excinfo, + mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.XcvrCacheUpdater.reinit_data') as mocked_xcvr_reinit_data, + mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.PsuCacheUpdater.reinit_data') as mocked_psu_reinit_data, + mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.FanDrawerCacheUpdater.reinit_data') as mocked_fan_drawer_reinit_data, + mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.FanCacheUpdater.reinit_data') as mocked_fan_cache_reinit_data, + mock.patch('sonic_ax_impl.mibs.ietf.rfc2737.ThermalCacheUpdater.reinit_data') as mocked_thermal_reinit_data): updater.reinit_data() - - # check warning - mocked_reinit_data.assert_called() + assert str(excinfo.value) == "mocked error" + mocked_xcvr_reinit_data.assert_called() + mocked_psu_reinit_data.assert_called() + mocked_fan_drawer_reinit_data.assert_called() + mocked_fan_cache_reinit_data.assert_called() + mocked_thermal_reinit_data.assert_called()