Exemple #1
0
def test_limit_rate_clips_wait_time_to_max_time(app):
    checker = CheckExternalLinksBuilder(app)
    app.config.linkcheck_rate_limit_timeout = 90.0
    checker.rate_limits = {"localhost": RateLimit(60.0, 0.0)}
    with mock.patch('time.time', return_value=0.0):
        next_check = checker.limit_rate(FakeResponse())
    assert next_check == 90.0
Exemple #2
0
def test_limit_rate_bails_out_after_waiting_max_time(app):
    checker = CheckExternalLinksBuilder(app)
    app.config.linkcheck_rate_limit_timeout = 90.0
    checker.rate_limits = {"localhost": RateLimit(90.0, 0.0)}
    next_check = checker.limit_rate(FakeResponse())
    assert next_check is None
Exemple #3
0
def test_limit_rate_user_max_delay(app):
    app.config.linkcheck_rate_limit_timeout = 0.0
    checker = CheckExternalLinksBuilder(app)
    checker.rate_limits = {}
    next_check = checker.limit_rate(FakeResponse())
    assert next_check is None
Exemple #4
0
def test_limit_rate_doubles_previous_wait_time(app):
    checker = CheckExternalLinksBuilder(app)
    checker.rate_limits = {"localhost": RateLimit(60.0, 0.0)}
    with mock.patch('time.time', return_value=0.0):
        next_check = checker.limit_rate(FakeResponse())
    assert next_check == 120.0
Exemple #5
0
def test_limit_rate_default_sleep(app):
    checker = CheckExternalLinksBuilder(app)
    checker.rate_limits = {}
    with mock.patch('time.time', return_value=0.0):
        next_check = checker.limit_rate(FakeResponse())
    assert next_check == 60.0