def test_add_subtract_examine(): q = StablePriorityQueue() q.add_task("b", priority=2) q.add_task("a", priority=1) q.add_task(0, priority=0) q.add_task("c", priority=2) q.remove_task(0) assert q.pop_task() == "a" assert q.peek_at_task() == "b" assert np.all(q.tasks_currently_in_queue() == np.array(["b", "c"])) assert q.pop_task() == "b" assert np.all(q.tasks_ever_in_queue() == np.array(["b", "a", "0", "c"]))
def test_add_subtract_examine(): q = StablePriorityQueue() q.add_task('b', priority=2) q.add_task('a', priority=1) q.add_task(0, priority=0) q.add_task('c', priority=2) q.remove_task(0) assert q.pop_task() == 'a' assert q.peek_at_task() == 'b' assert np.all(q.tasks_currently_in_queue() == np.array(['b', 'c'])) assert q.pop_task() == 'b' assert np.all(q.tasks_ever_in_queue() == np.array(['b', 'a', '0', 'c']))
def test_empty_peek(): q = StablePriorityQueue() with pytest.raises(KeyError): q.peek_at_task()