Esempio n. 1
0
def test_limit_rate_bails_out_after_waiting_max_time(app):
    app.config.linkcheck_rate_limit_timeout = 90.0
    rate_limits = {"localhost": RateLimit(90.0, 0.0)}
    worker = HyperlinkAvailabilityCheckWorker(app.env, app.config, Queue(), Queue(),
                                              rate_limits)
    next_check = worker.limit_rate(FakeResponse())
    assert next_check is None
Esempio n. 2
0
def test_limit_rate_doubles_previous_wait_time(app):
    rate_limits = {"localhost": RateLimit(60.0, 0.0)}
    worker = HyperlinkAvailabilityCheckWorker(app.env, app.config, Queue(), Queue(),
                                              rate_limits)
    with mock.patch('time.time', return_value=0.0):
        next_check = worker.limit_rate(FakeResponse())
    assert next_check == 120.0
Esempio n. 3
0
def test_limit_rate_clips_wait_time_to_max_time(app):
    app.config.linkcheck_rate_limit_timeout = 90.0
    rate_limits = {"localhost": RateLimit(60.0, 0.0)}
    worker = HyperlinkAvailabilityCheckWorker(app.env, app.config, Queue(), Queue(),
                                              rate_limits)
    with mock.patch('time.time', return_value=0.0):
        next_check = worker.limit_rate(FakeResponse())
    assert next_check == 90.0
Esempio n. 4
0
def test_limit_rate_bails_out_after_waiting_max_time(app):
    checker = CheckExternalLinksBuilder(app)
    checker.init()
    app.config.linkcheck_rate_limit_timeout = 90.0
    checker.rate_limits = {"localhost": RateLimit(90.0, 0.0)}
    worker = HyperlinkAvailabilityCheckWorker(checker)
    next_check = worker.limit_rate(FakeResponse())
    assert next_check is None
Esempio n. 5
0
def test_limit_rate_doubles_previous_wait_time(app):
    checker = CheckExternalLinksBuilder(app)
    checker.init()
    checker.rate_limits = {"localhost": RateLimit(60.0, 0.0)}
    worker = HyperlinkAvailabilityCheckWorker(checker)
    with mock.patch('time.time', return_value=0.0):
        next_check = worker.limit_rate(FakeResponse())
    assert next_check == 120.0
Esempio n. 6
0
def test_limit_rate_user_max_delay(app):
    app.config.linkcheck_rate_limit_timeout = 0.0
    checker = CheckExternalLinksBuilder(app)
    checker.init()
    checker.rate_limits = {}
    worker = HyperlinkAvailabilityCheckWorker(checker)
    next_check = worker.limit_rate(FakeResponse())
    assert next_check is None
Esempio n. 7
0
def test_limit_rate_default_sleep(app):
    checker = CheckExternalLinksBuilder(app)
    checker.init()
    checker.rate_limits = {}
    worker = HyperlinkAvailabilityCheckWorker(checker)
    with mock.patch('time.time', return_value=0.0):
        next_check = worker.limit_rate(FakeResponse())
    assert next_check == 60.0
Esempio n. 8
0
def test_limit_rate_clips_wait_time_to_max_time(app):
    checker = CheckExternalLinksBuilder(app)
    checker.init()
    app.config.linkcheck_rate_limit_timeout = 90.0
    checker.rate_limits = {"localhost": RateLimit(60.0, 0.0)}
    worker = HyperlinkAvailabilityCheckWorker(checker)
    with mock.patch('time.time', return_value=0.0):
        next_check = worker.limit_rate(FakeResponse())
    assert next_check == 90.0
Esempio n. 9
0
def test_limit_rate_user_max_delay(app):
    app.config.linkcheck_rate_limit_timeout = 0.0
    worker = HyperlinkAvailabilityCheckWorker(app.env, app.config, Queue(), Queue(), {})
    next_check = worker.limit_rate(FakeResponse())
    assert next_check is None
Esempio n. 10
0
def test_limit_rate_default_sleep(app):
    worker = HyperlinkAvailabilityCheckWorker(app.env, app.config, Queue(), Queue(), {})
    with mock.patch('time.time', return_value=0.0):
        next_check = worker.limit_rate(FakeResponse())
    assert next_check == 60.0