mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-08-31 23:20:03 +02:00
Improve unit test performance. (Do not install library we do not use in the tests anyway.) (#92)
This commit is contained in:
parent
ea782c1cf2
commit
5f912dad16
6 changed files with 8 additions and 19 deletions
|
@ -34,7 +34,8 @@ class fake_ros_api(object):
|
|||
def __init__(self, api, path):
|
||||
pass
|
||||
|
||||
def path(self, api, path):
|
||||
@classmethod
|
||||
def path(cls, api, path):
|
||||
fake_bridge = [{".id": "*DC", "name": "b2", "mtu": "auto", "actual-mtu": 1500,
|
||||
"l2mtu": 65535, "arp": "enabled", "arp-timeout": "auto",
|
||||
"mac-address": "3A:C1:90:D6:E8:44", "protocol-mode": "rstp",
|
||||
|
@ -45,7 +46,8 @@ class fake_ros_api(object):
|
|||
"dhcp-snooping": "false", "running": "true", "disabled": "false"}]
|
||||
return fake_bridge
|
||||
|
||||
def arbitrary(self, api, path):
|
||||
@classmethod
|
||||
def arbitrary(cls, api, path):
|
||||
def retr(self, *args, **kwargs):
|
||||
if 'name' not in kwargs.keys():
|
||||
raise TrapError(message="no such command")
|
||||
|
@ -90,7 +92,8 @@ class fake_ros_api(object):
|
|||
else:
|
||||
return ["no results for 'interface bridge 'query' %s" % ' '.join(args)]
|
||||
|
||||
def select_where(self, api, path):
|
||||
@classmethod
|
||||
def select_where(cls, api, path):
|
||||
api_path = Where()
|
||||
return api_path
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ class TestRouterosApiModule(ModuleTestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestRouterosApiModule, self).setUp()
|
||||
librouteros = pytest.importorskip("librouteros")
|
||||
self.module = api
|
||||
self.module.LibRouterosError = FakeLibRouterosError
|
||||
self.module.connect = MagicMock(new=fake_ros_api)
|
||||
self.module.check_has_library = MagicMock()
|
||||
self.patch_create_api = patch('ansible_collections.community.routeros.plugins.modules.api.create_api', MagicMock(new=fake_ros_api))
|
||||
self.patch_create_api.start()
|
||||
self.module.Key = MagicMock(new=Key)
|
||||
|
|
|
@ -424,10 +424,10 @@ class TestRouterosApiFactsModule(ModuleTestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestRouterosApiFactsModule, self).setUp()
|
||||
librouteros = pytest.importorskip('librouteros')
|
||||
self.module = api_facts
|
||||
self.module.LibRouterosError = FakeLibRouterosError
|
||||
self.module.connect = MagicMock(new=fake_ros_api)
|
||||
self.module.check_has_library = MagicMock()
|
||||
self.patch_create_api = patch('ansible_collections.community.routeros.plugins.modules.api_facts.create_api', MagicMock(new=fake_ros_api))
|
||||
self.patch_create_api.start()
|
||||
self.patch_query_path = patch('ansible_collections.community.routeros.plugins.modules.api_facts.FactsBase.query_path', self.query_path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue