@@ -48,6 +48,23 @@ def pytest_addoption(parser):
4848
4949@pytest .fixture
5050def fakeicontrolsession (monkeypatch ):
51+ class Response (object ):
52+
53+ def json (self ):
54+ return {'selfLink' : 'https://localhost/mgmt/tm/sys?ver=11.6.0' }
55+
56+ fakesessionclass = mock .create_autospec (iControlRESTSession , spec_set = True )
57+ fakesessioninstance = mock .create_autospec (iControlRESTSession ('A' , 'B' ),
58+ spec_set = True )
59+ fakesessioninstance .get = \
60+ mock .MagicMock (return_value = Response ())
61+ fakesessionclass .return_value = fakesessioninstance
62+ monkeypatch .setattr ('f5.bigip.iControlRESTSession' , fakesessionclass )
63+
64+
65+
66+ @pytest .fixture
67+ def fakeicontrolsessionfactory (monkeypatch ):
5168 class Response (object ):
5269 def __init__ (self , ** json_keys ):
5370 if 'selfLink' not in json_keys :
@@ -58,13 +75,17 @@ def __init__(self, **json_keys):
5875 def json (self ):
5976 return self .params
6077
61- fakesessionclass = mock .create_autospec (iControlRESTSession , spec_set = True )
62- fakesessioninstance = \
63- mock .create_autospec (iControlRESTSession ('A' , 'B' ), spec_set = True )
64- fakesessioninstance .get = mock .MagicMock (return_value = Response ())
65- fakesessionclass .return_value = fakesessioninstance
66- monkeypatch .setattr ('f5.bigip.iControlRESTSession' , fakesessionclass )
67-
78+ def _session_factory (** json_keys ):
79+ fakesessionclass = mock .create_autospec (iControlRESTSession ,
80+ spec_set = True )
81+ fakesessioninstance = \
82+ mock .create_autospec (iControlRESTSession ('A' , 'B' ), spec_set = True )
83+ fakesessioninstance .get = \
84+ mock .MagicMock (return_value = Response (** json_keys ))
85+ fakesessionclass .return_value = fakesessioninstance
86+ monkeypatch .setattr ('f5.bigip.iControlRESTSession' , fakesessionclass )
87+
88+ return _session_factory
6889
6990@pytest .fixture
7091def fakeicontrolsession_v12 (monkeypatch ):
0 commit comments