diff --git a/tests/lib/mockMagic.py b/tests/lib/mockMagic.py index 4e2e3fe02..a23b59278 100644 --- a/tests/lib/mockMagic.py +++ b/tests/lib/mockMagic.py @@ -1,11 +1,9 @@ from tests.data.device_tools_unit import validate_router_bgp, return_validate_config_for_device, validate_intf, validate_true -from unittest.mock import MagicMock -class MockCvpApi(MagicMock): - def validate_config_for_device(self, device_mac, config): - if config == validate_router_bgp['config']: - return return_validate_config_for_device['return_validate_ruter_bgp'] - if config == validate_intf['config']: - return return_validate_config_for_device['return_validate_intf'] - if config == validate_true['config']: - return return_validate_config_for_device['return_validate_true'] +def validate_config_for_device(device_mac, config): + if config == validate_router_bgp['config']: + return return_validate_config_for_device['return_validate_ruter_bgp'] + if config == validate_intf['config']: + return return_validate_config_for_device['return_validate_intf'] + if config == validate_true['config']: + return return_validate_config_for_device['return_validate_true'] diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index e66c05e52..da700d257 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -22,5 +22,6 @@ def mock_cvpClient(): """ # mocked cvpClient object mock_cvpClient = create_autospec(CvpClient) - mock_cvpClient.api = mockMagic.MockCvpApi(spec=CvpApi) + mock_cvpClient.api = create_autospec(spec=CvpApi) + mock_cvpClient.api.validate_config_for_device.side_effect = mockMagic.validate_config_for_device return mock_cvpClient