Skip to content

Commit

Permalink
add a unit test for reschedule
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourour Benzarti committed Jul 24, 2024
1 parent e405ce5 commit c7606f2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_task_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ def test_reschedule(task_queue: TaskQueue):
assert qname == "test_queue"


def test_reschedule_with_ttl(task_queue: TaskQueue):
task_queue.add({"foo": 1}, LEASE_TIMEOUT, 2)
_, id_, qname = task_queue.get()
# task queue should be empty as 'foo' is in the processing queue
assert task_queue.get() == (None, None, None)
assert qname == "test_queue"
task_queue.reschedule(id_, decrease_ttl=True)
task, _, qname = task_queue.get()
assert task == {"foo": 1}
# task queue should be empty because the task is expired(ttl=0)
assert task_queue.get() == (None, None, None)


def test_reschedule_error(task_queue: TaskQueue):
with pytest.raises(ValueError):
task_queue.reschedule("bar")
Expand Down

0 comments on commit c7606f2

Please sign in to comment.