def test_peek_when_empty(): # TODO it should raise an exception when peeking an empty queue q = Queue() with pytest.raises(InvalidOperationError) as e: q.peek() assert str(e.value) == "Method not allowed on empty collection"
def test_peek_post_dequeue(): # TODO it should return a new first value if peek is called after a dequeue q = Queue() q.enqueue('apples') q.enqueue('oranges') actual = q.peek() expected = 'apples' assert actual == expected q.dequeue() actual = q.peek() expected = 'oranges' assert actual == expected
def test_enqueue_two(): q = Queue() q.enqueue("apples") q.enqueue("bananas") actual = q.peek() expected = "apples" assert actual == expected
def test_can_peek_queue(): queue = Queue() queue.enqueue(1) queue.enqueue(2) actual = queue.peek() expected = 1 assert actual == expected
def test_queue_peek(): value = 1 node = Node(value) queue = Queue(node) actual = queue.peek() expected = value assert actual == expected
def test_peek(): q = Queue() q.enqueue("apple") q.enqueue("banana") q.enqueue("cucumber") actual = q.peek() expected = "apple" assert actual == expected
def test_raise_exception_empty_queue(): queue = Queue() with pytest.raises(InvalidOperationError) as e: queue.peek() assert str(e.value) == "Peeking from an empty queue!"
def test_queue_peek_empty_exception(): queue = Queue() with pytest.raises(Exception): queue.peek()