Skip to content

Commit

Permalink
Test: Unittest lib restructuring (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
sugetha24 authored May 4, 2023
1 parent f8b8e40 commit a3b7d8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 7 additions & 9 deletions tests/lib/mockMagic.py
Original file line number Diff line number Diff line change
@@ -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']
3 changes: 2 additions & 1 deletion tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a3b7d8c

Please sign in to comment.