# Path: zoonado/retry.py
# class RetryPolicy(object):
#     def __init__(self, try_limit, sleep_func):
#     def enforce(self, request=None):
#     def clear(self, request):
#     def once(cls):
#     def n_times(cls, n):
#         def never_wait(_):
#     def forever(cls):
#         def never_wait(_):
#     def exponential_backoff(cls, base=2, maximum=None):
#         def exponential(timings):
#     def until_elapsed(cls, timeout):
#         def elapsed_time(timings):
# 
# Path: zoonado/exc.py
# class ZKError(Exception):
# class ConnectError(ZKError):
# class NoServersError(ZKError):
# class SessionLost(ZKError):
# class InvalidClientState(ZKError):
# class TimeoutError(ZKError):
# class FailedRetry(ZKError):
# class ResponseErrorMeta(type):
# class ResponseError(ZKError):
# class UnknownError(ResponseError):
# class RolledBack(ResponseError):
# class ZKSystemError(ResponseError):
# class RuntimeInconsistency(ResponseError):
# class DataInconsistency(ResponseError):
# class ConnectionLoss(ResponseError):
# class MarshallingError(ResponseError):
# class Unimplemented(ResponseError):
# class OperationTimeout(ResponseError):
# class BadArguments(ResponseError):
# class UnknownSession(ResponseError):
# class NewConfigNoQuorum(ResponseError):
# class ReconfigInProcess(ResponseError):
# class APIError(ResponseError):
# class NoNode(ResponseError):
# class NoAuth(ResponseError):
# class BadVersion(ResponseError):
# class NoChildrenForEphemerals(ResponseError):
# class NodeExists(ResponseError):
# class NotEmpty(ResponseError):
# class SessionExpired(ResponseError):
# class InvalidCallback(ResponseError):
# class InvalidACL(ResponseError):
# class AuthFailed(ResponseError):
# class SessionMoved(ResponseError):
# class NotReadOnly(ResponseError):
# class EphemeralOnLocalSession(ResponseError):
# class NoWatcher(ResponseError):
#     def __init__(self, host, port, server_id=None):
#     def __str__(self):
#     def __new__(cls, name, bases, attrs):
#     def __str__(self):
#     def __init__(self, error_code):
#     def __str__(self):
# def get_response_error(error_code):


import time
from mock import patch, Mock
from tornado import testing, concurrent
from zoonado import retry, exc
            yield policy.enforce(request)

    @testing.gen_test
    def test_timeout_failure(self):

        def in_the_past(_):
            return -1

        request = Mock()

        policy = retry.RetryPolicy(try_limit=3, sleep_func=in_the_past)

        yield policy.enforce(request)

        with self.assertRaises(exc.FailedRetry):
            yield policy.enforce(request)

    @patch.object(retry.gen, "sleep")
    @testing.gen_test
    def test_enforcing_wait_time_sleeps(self, mock_gen_sleep):
        f = concurrent.Future()
        f.set_result(None)

        mock_gen_sleep.return_value = f

        def in_the_future(_):
            return 60

        request = Mock()


# Path: zoonado/retry.py
# class RetryPolicy(object):
#     def __init__(self, try_limit, sleep_func):
#     def enforce(self, request=None):
#     def clear(self, request):
#     def once(cls):
#     def n_times(cls, n):
#         def never_wait(_):
#     def forever(cls):
#         def never_wait(_):
#     def exponential_backoff(cls, base=2, maximum=None):
#         def exponential(timings):
#     def until_elapsed(cls, timeout):
#         def elapsed_time(timings):
# 
# Path: zoonado/exc.py
# class ZKError(Exception):
# class ConnectError(ZKError):
# class NoServersError(ZKError):
# class SessionLost(ZKError):
# class InvalidClientState(ZKError):
# class TimeoutError(ZKError):
# class FailedRetry(ZKError):
# class ResponseErrorMeta(type):
# class ResponseError(ZKError):
# class UnknownError(ResponseError):
# class RolledBack(ResponseError):
# class ZKSystemError(ResponseError):
# class RuntimeInconsistency(ResponseError):
# class DataInconsistency(ResponseError):
# class ConnectionLoss(ResponseError):
# class MarshallingError(ResponseError):
# class Unimplemented(ResponseError):
# class OperationTimeout(ResponseError):
# class BadArguments(ResponseError):
# class UnknownSession(ResponseError):
# class NewConfigNoQuorum(ResponseError):
# class ReconfigInProcess(ResponseError):
# class APIError(ResponseError):
# class NoNode(ResponseError):
# class NoAuth(ResponseError):
# class BadVersion(ResponseError):
# class NoChildrenForEphemerals(ResponseError):
# class NodeExists(ResponseError):
# class NotEmpty(ResponseError):
# class SessionExpired(ResponseError):
# class InvalidCallback(ResponseError):
# class InvalidACL(ResponseError):
# class AuthFailed(ResponseError):
# class SessionMoved(ResponseError):
# class NotReadOnly(ResponseError):
# class EphemeralOnLocalSession(ResponseError):
# class NoWatcher(ResponseError):
#     def __init__(self, host, port, server_id=None):
#     def __str__(self):
#     def __new__(cls, name, bases, attrs):
#     def __str__(self):
#     def __init__(self, error_code):
#     def __str__(self):
# def get_response_error(error_code):


# Path: tests/test_retry.py
import time
from mock import patch, Mock
from tornado import testing, concurrent
from zoonado import retry, exc

            yield policy.enforce(request)

    @testing.gen_test
    def test_timeout_failure(self):

        def in_the_past(_):
            return -1

        request = Mock()

        policy = retry.RetryPolicy(try_limit=3, sleep_func=in_the_past)

        yield policy.enforce(request)

        with self.assertRaises(exc.FailedRetry):
            yield policy.enforce(request)

    @patch.object(retry.gen, "sleep")
    @testing.gen_test
    def test_enforcing_wait_time_sleeps(self, mock_gen_sleep):
        f = concurrent.Future()
        f.set_result(None)

        mock_gen_sleep.return_value = f

        def in_the_future(_):
            return 60

        request = Mock()


        policy = retry.RetryPolicy(try_limit=3, sleep_func=in_the_future)