Skip to content

Instantly share code, notes, and snippets.

@zancas
Created June 2, 2016 18:27
Show Gist options
  • Save zancas/d2e8b822ac999e71eeac1dbba961a1f8 to your computer and use it in GitHub Desktop.
Save zancas/d2e8b822ac999e71eeac1dbba961a1f8 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
from icontrol.session import iControlRESTSession
@pytest.fixture
def fakeicontrolsession(monkeypatch):
class Response(object):
def json(self):
return {'selfLink': 'https://localhost/mgmt/tm/sys?ver=11.6.0'}
fakesessionclass = mock.create_autospec(iControlRESTSession, spec_set=True)
fakesessioninstance =\
mock.create_autospec(iControlRESTSession('A', 'B'), spec_set=True)
fakesessioninstance.get = mock.MagicMock(return_value=Response())
fakesessionclass.return_value = fakesessioninstance
monkeypatch.setattr('f5.bigip.iControlRESTSession', fakesessionclass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment