Skip to content

Commit 21d8495

Browse files
committed
Make fakeicontrolsession more flexible
1 parent 8168412 commit 21d8495

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,15 @@ def pytest_addoption(parser):
4949
@pytest.fixture
5050
def fakeicontrolsession(monkeypatch):
5151
class Response(object):
52+
def __init__(self, **json_keys):
53+
if 'selfLink' not in json_keys:
54+
json_keys['selfLink'] =\
55+
'https://localhost/mgmt/tm/sys?ver=11.6.0'
56+
self.params = json_keys
57+
5258
def json(self):
53-
return {'selfLink': 'https://localhost/mgmt/tm/sys?ver=11.6.0'}
59+
return self.params
60+
5461
fakesessionclass = mock.create_autospec(iControlRESTSession, spec_set=True)
5562
fakesessioninstance =\
5663
mock.create_autospec(iControlRESTSession('A', 'B'), spec_set=True)
@@ -72,7 +79,7 @@ def json(self):
7279
monkeypatch.setattr('f5.bigip.iControlRESTSession', fakesessionclass)
7380

7481

75-
@pytest.fixture
82+
@pytest.fixture(scope='session')
7683
def opt_bigip(request):
7784
return request.config.getoption("--bigip")
7885

0 commit comments

Comments
 (0)