How to use the somecomfort.SomeComfort.keepalive.side_effect function in somecomfort

To help you get started, we’ve selected a few somecomfort examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kk7ds / somecomfort / tests / test_client.py View on Github external
def test_relogin(self):
        recorder = betamax.Betamax(self.session)
        with recorder.use_cassette('relogin'):
            with mock.patch.multiple(
                    'somecomfort.SomeComfort',
                    _login=mock.DEFAULT,
                    _discover=mock.DEFAULT,
                    keepalive=mock.DEFAULT) as (l, d, k):
                SomeComfort.keepalive.side_effect = somecomfort.SessionTimedOut
                c = SomeComfort(self.username, self.password)
                c._login.assert_called_once_with()
            with mock.patch.object(c, 'keepalive') as mock_k:
                tries = [1]

                def fake_keepalive():
                    if tries:
                        tries.pop()
                        raise somecomfort.SessionTimedOut()

                mock_k.side_effect = fake_keepalive
                c._discover()