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
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
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
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
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
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
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