@pytest.fixture
def throttle_history(expired_throttle_history, retry_after_value):
    """
    Contains multiple randomly generated throttle snapshots in storage. There
    is one snapshot where search service has black status and a retry-after
    value.
    """
    storage = expired_throttle_history
    system_stats = ('idle', 'busy', 'overloaded')
    lights = ('green', 'yellow', 'red')
    sample_count = 4
    expected = {}
    service_limits = {}

    def _range(end, step=-10):
        start = end + -step - (sample_count - 1)
        return range(start, end - 1, step)

    def _services_dicts(limits):
        snapshots = []
        for i in range(sample_count):
            sd = {}
            for k, v in limits.items():
                sd[k] = (choice(lights), v[i])
            snapshots.append(sd)
        return snapshots

    for service, limit in zip(SQLite.SERVICES, (200, 100, 60, 10, 5)):
        expected[service] = 60. / limit
        service_limits[service] = list(_range(limit))
        shuffle(service_limits[service])

    for d in _services_dicts(service_limits):
        storage.update(make_header(
            make_throttle_snapshot(choice(system_stats), d).as_header()
        ))

    # Make a special header with search=black with retry value
    services = list(SQLite.SERVICES)
    services.remove('search')
    services = ', '.join(['{0}=green:1000'.format(s) for s in services])
    storage.update(
        make_header(
            '{0} (search=black:0, {1})'.format(choice(system_stats), services),
            retry_after_value
        )
    )

    # Make sure to override expected
    expected['search'] = retry_after_value / 1000.

    th = {'expected': expected, 'storage': storage}
    return th
dataset/ETHPy150Open 55minutes/python-epo-ops-client/tests/middlewares/throttle/conftest.py/throttle_history/operator `*` -> `-`