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"
    pass
def queue_vals():
    queue = Queue()
    queue.enqueue(8)
    queue.enqueue('hi')
    queue.enqueue(-4)
    queue.enqueue(6)
    return queue
def test_peek():
    q = Queue()
    q.enqueue("apple")
    q.enqueue("banana")
    q.enqueue("cucumber")
    actual = q.peek()
    expected = "apple"
    assert actual == expected
def test_dequeue_when_full():
    q = Queue()
    q.enqueue("apples")
    q.enqueue("bananas")
    actual = q.dequeue()
    expected = "apples"
    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_enqueue(queue_vals):

    # no nodes
    q = Queue()
    assert q.front == None
    assert q.rear == None

    # only one node
    q.enqueue(5)
    assert q.front.value == 5
    assert q.rear.value == 5

    # two nodes
    q.enqueue(7)
    assert q.front.value == 5
    assert q.rear.value == 7

    assert queue_vals.rear.value == 6
    assert queue_vals.front.value == 8
def test_is_empty(queue_vals):
    q = Queue()
    assert q.is_empty() == True
    assert queue_vals.is_empty() == False
def test_peek(queue_vals):
    q = Queue()
    assert q.peek() == 'this is an empty Stack'
    assert queue_vals.peek() == 8
def test_exhausted():
    #  TODO TODO is empty should return true after dequeueing all previously queued items
    q = Queue()
    q.enqueue("apples")
    q.enqueue("bananas")
    q.enqueue("grapes")
    q.dequeue()
    q.dequeue()
    q.dequeue()
    actual = q.is_empty()
    expected = True
    assert actual == expected
def test_is_empty():
    #  TODO is empty should return true if no items were enqueued
    q = Queue()
    actual = q.is_empty()
    expected = True
    assert actual == expected
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("bananas")
    q.enqueue("grapes")
    q.dequeue()
    actual = q.peek()
    expected = "bananas"
    assert actual == expected
def test_enqueue():
    q = Queue()
    q.enqueue("apple")
    actual = q.front.value
    expected = "apple"
    assert actual == expected