# Path: aiobotocore/retries/adaptive.py
# def register_retry_handler(client):
#     def __init__(self, rate_adjustor, rate_clocker, token_bucket,
#                  throttling_detector, clock):
#     async def on_sending_request(self, request, **kwargs):
#     async def on_receiving_response(self, **kwargs):
# class AsyncClientRateLimiter:
#     _MAX_RATE_ADJUST_SCALE = 2.0
# 
# Path: aiobotocore/retries/bucket.py
# class AsyncTokenBucket:
#     _MIN_RATE = 0.5
#     def __init__(self, max_rate, clock, min_rate=_MIN_RATE):
#     def max_rate(self):
#     async def set_max_rate(self, value):
#     def _set_max_rate(self, value):
#     def max_capacity(self):
#     def available_capacity(self):
#     async def acquire(self, amount=1, block=True):
#     async def _acquire(self, amount, block):
#     def _sleep_amount(self, amount):
#     def _refill(self):


from unittest import mock
from aiobotocore.retries import adaptive
from aiobotocore.retries import bucket
from botocore.retries import throttling
from botocore.retries import standard
from botocore.exceptions import CapacityNotAvailableError
import pytest
    @pytest.mark.asyncio
    async def test_max_rate_updated_on_success_response(self):
        rate_limiter = self.create_client_limiter()
        self.throttling_detector.is_throttling_error.return_value = False
        self.rate_adjustor.success_received.return_value = 20
        self.rate_clocker.record.return_value = 21
        await rate_limiter.on_receiving_response()
        assert await self.token_bucket.set_max_rate.called_with(20)

    @pytest.mark.asyncio
    async def test_max_rate_cant_exceed_20_percent_max(self):
        rate_limiter = self.create_client_limiter()
        self.throttling_detector.is_throttling_error.return_value = False
        # So if our actual measured sending rate is 20 TPS
        self.rate_clocker.record.return_value = 20
        # But the rate adjustor is telling us to go up to 100 TPS
        self.rate_adjustor.success_received.return_value = 100

        # The most we should go up is 2.0 * 20
        await rate_limiter.on_receiving_response()
        assert await self.token_bucket.set_max_rate.called_with(2.0 * 20)


class TestAsyncTokenBucket:
    @pytest.fixture(autouse=True)
    def _setup(self):
        self.timestamp_sequences = [0]
        self.clock = FakeClock(self.timestamp_sequences)

    def create_token_bucket(self, max_rate=10, min_rate=0.1):

# Path: aiobotocore/retries/adaptive.py
# def register_retry_handler(client):
#     def __init__(self, rate_adjustor, rate_clocker, token_bucket,
#                  throttling_detector, clock):
#     async def on_sending_request(self, request, **kwargs):
#     async def on_receiving_response(self, **kwargs):
# class AsyncClientRateLimiter:
#     _MAX_RATE_ADJUST_SCALE = 2.0
# 
# Path: aiobotocore/retries/bucket.py
# class AsyncTokenBucket:
#     _MIN_RATE = 0.5
#     def __init__(self, max_rate, clock, min_rate=_MIN_RATE):
#     def max_rate(self):
#     async def set_max_rate(self, value):
#     def _set_max_rate(self, value):
#     def max_capacity(self):
#     def available_capacity(self):
#     async def acquire(self, amount=1, block=True):
#     async def _acquire(self, amount, block):
#     def _sleep_amount(self, amount):
#     def _refill(self):


# Path: tests/test_adaptive.py
from unittest import mock
from aiobotocore.retries import adaptive
from aiobotocore.retries import bucket
from botocore.retries import throttling
from botocore.retries import standard
from botocore.exceptions import CapacityNotAvailableError
import pytest

    @pytest.mark.asyncio
    async def test_max_rate_updated_on_success_response(self):
        rate_limiter = self.create_client_limiter()
        self.throttling_detector.is_throttling_error.return_value = False
        self.rate_adjustor.success_received.return_value = 20
        self.rate_clocker.record.return_value = 21
        await rate_limiter.on_receiving_response()
        assert await self.token_bucket.set_max_rate.called_with(20)

    @pytest.mark.asyncio
    async def test_max_rate_cant_exceed_20_percent_max(self):
        rate_limiter = self.create_client_limiter()
        self.throttling_detector.is_throttling_error.return_value = False
        # So if our actual measured sending rate is 20 TPS
        self.rate_clocker.record.return_value = 20
        # But the rate adjustor is telling us to go up to 100 TPS
        self.rate_adjustor.success_received.return_value = 100

        # The most we should go up is 2.0 * 20
        await rate_limiter.on_receiving_response()
        assert await self.token_bucket.set_max_rate.called_with(2.0 * 20)


class TestAsyncTokenBucket:
    @pytest.fixture(autouse=True)
    def _setup(self):
        self.timestamp_sequences = [0]
        self.clock = FakeClock(self.timestamp_sequences)

    def create_token_bucket(self, max_rate=10, min_rate=0.1):

        return bucket.AsyncTokenBucket(