def test_watch_client_request_failed(self): path = '/test' m_handler = mock.Mock() watcher_obj = self._test_watch_create_watcher(path, m_handler) watcher_obj._watch(path) self.client.watch.side_effect = exceptions.ChunkedEncodingError( "Connection Broken") self.client.watch.assert_called_once() self.assertFalse(watcher_obj._healthy)
def test_watch_retry(self): path = '/test' events = [{'e': i} for i in range(3)] side_effects = [exceptions.ChunkedEncodingError("Connection Broken")] side_effects.extend(None for _ in events) m_handler = mock.Mock() m_handler.side_effect = side_effects watcher_obj = self._test_watch_create_watcher(path, m_handler, 10) self._test_watch_mock_events(watcher_obj, events) watcher_obj._watch(path) m_handler.assert_has_calls([mock.call(e) for e in events])
def handler(event): if self.retry: self.retry = False raise exceptions.ChunkedEncodingError("Connection Broken")