Exemple #1
0
def test_update_with_header(storage, header, throttle_snapshot,
                            retry_after_value):
    start = now()
    storage.update(header)
    assert table_count(storage) == 1
    assert now() > single_col_query(storage, "timestamp") > start
    assert single_col_query(
        storage, "system_status") == (throttle_snapshot.system_status)
    for s in throttle_snapshot.service_statuses:
        for service, (col, val) in product([s.service],
                                           zip(("status", "limit"),
                                               (s.status, s.limit))):
            col = "{0}_{1}".format(service, col)
            assert single_col_query(storage, col) == val

        if s.status.lower() == "black":
            col = "{0}_retry_after".format(s.service)
            assert single_col_query(storage, col) == retry_after_value
Exemple #2
0
def test_update_with_header(storage, header, throttle_snapshot,
                            retry_after_value):
    start = now()
    storage.update(header)
    assert table_count(storage) == 1
    assert now() > single_col_query(storage, 'timestamp') > start
    assert single_col_query(
        storage, 'system_status') == (throttle_snapshot.system_status)
    for s in throttle_snapshot.service_statuses:
        for service, (col, val) in product([s.service],
                                           zip(('status', 'limit'),
                                               (s.status, s.limit))):
            col = '{0}_{1}'.format(service, col)
            assert single_col_query(storage, col) == val

        if s.status.lower() == 'black':
            col = '{0}_retry_after'.format(s.service)
            assert single_col_query(storage, col) == retry_after_value
def test_update_with_header(
    storage, header, throttle_snapshot, retry_after_value
):
    start = now()
    storage.update(header)
    assert table_count(storage) == 1
    assert now() > single_col_query(storage, 'timestamp') > start
    assert single_col_query(storage, 'system_status') ==\
        throttle_snapshot.system_status
    for s in throttle_snapshot.service_statuses:
        for service, (col, val) in product(
            [s.service], zip(('status', 'limit'), (s.status, s.limit))
        ):
            col = '{0}_{1}'.format(service, col)
            assert single_col_query(storage, col) == val

        if s.status.lower() == 'black':
            col = '{0}_retry_after'.format(s.service)
            assert single_col_query(storage, col) == retry_after_value
def generate_timestamps(deltas):
    timestamps = []
    for d in deltas:
        timestamps.append(now() - timedelta(minutes=d))
    return timestamps
def test_sqlite_timestamp_conversion(storage):
    dt = now()
    sql = 'INSERT INTO throttle_history(timestamp) VALUES (?)'
    with storage.db:
        storage.db.execute(sql, (dt,))
    assert single_col_query(storage, 'timestamp') == dt
Exemple #6
0
def test_sqlite_timestamp_conversion(storage):
    dt = now()
    sql = "INSERT INTO throttle_history(timestamp) VALUES (?)"
    with storage.db:
        storage.db.execute(sql, (dt, ))
    assert single_col_query(storage, "timestamp") == dt
Exemple #7
0
def generate_timestamps(deltas):
    return [now() - timedelta(minutes=d) for d in deltas]
def generate_timestamps(deltas):
    timestamps = []
    for d in deltas:
        timestamps.append(now() - timedelta(minutes=d))
    return timestamps
def generate_timestamps(deltas):
    return [now() - timedelta(minutes=d) for d in deltas]