def test_ttr(c: Client) -> None: c.put(b"two second ttr", ttr=2) with assert_seconds(1): job = c.reserve() with pytest.raises(DeadlineSoonError): c.reserve() with assert_seconds(1): c.touch(job) with pytest.raises(DeadlineSoonError): c.reserve() c.release(job)
def test_delays(c: Client) -> None: with assert_seconds(1): c.put(b"delayed", delay=1) job = c.reserve() assert job.body == b"delayed" with assert_seconds(2): c.release(job, delay=2) with pytest.raises(TimedOutError): c.reserve(timeout=1) job = c.reserve(timeout=1) c.bury(job) with pytest.raises(TimedOutError): c.reserve(timeout=0)