def test_pseudo_queue_dequeue_many(stack_of_four_nodes):
    new_queue = PseudoQueue(stack_of_four_nodes)
    assert new_queue.stack_a.peek() == 4
    assert new_queue.dequeue() == 1
    assert new_queue.dequeue() == 2
    assert new_queue.stack_a.peek() == 4
    assert new_queue.dequeue() == 3
    assert new_queue.dequeue() == 4
    assert new_queue.stack_a.peek() == None
Beispiel #2
0
def test_PseudoQueue_enqueue():
	stack_one = Stack()
	stack_one.push(10)
	stack_one.push(5)
	stack_one.push(0)
	queue = PseudoQueue(stack_one)
	queue.enqueue(15)
	actual = str(queue)
	expected = '0 ->5 ->10 ->15'
	assert actual == expected
def test_dequeue():
    pseudo = PseudoQueue()
    pseudo.enqueue(20)
    pseudo.enqueue(15)
    pseudo.enqueue(10)
    pseudo.enqueue(5)
    expected = 5
    actual = pseudo.dequeue(5)
    assert actual == expected
Beispiel #4
0
def test_enqueue_dequeue(my_stack):
    pseudo_q = PseudoQueue(my_stack)
    assert pseudo_q.stack1.peek() == 10
    pseudo_q.enqueue('cat')
    assert pseudo_q.stack1.peek() == 'cat'
    pseudo_q.enqueue('dog')
    assert pseudo_q.stack1.peek() == 'dog'
    assert pseudo_q.dequeue() == 'a'
    assert pseudo_q.stack1.peek() == 'dog'
    assert pseudo_q.dequeue() == 'b'
    assert pseudo_q.stack1.peek() == 'dog'
    assert pseudo_q.dequeue() == 'c'
    assert pseudo_q.dequeue() == 10
    assert pseudo_q.dequeue() == 'cat'
    assert pseudo_q.dequeue() == 'dog'
def test_pseudoqueue_enqueue_many(stack_of_four_nodes):
    new_queue = PseudoQueue(stack_of_four_nodes)
    assert new_queue.stack_a.peek() == 4
    new_queue.enqueue('sunshine')
    assert new_queue.stack_a.peek() == 'sunshine'
    new_queue.enqueue('mangosteen')
    new_queue.enqueue(8)
    assert new_queue.stack_a.peek() == 8
def test_dequeue_two():
    queue = PseudoQueue()
    queue.enqueue(Stack())
    queue.front.push('First')
    queue.enqueue(Stack())
    queue.rear.push('Second')
    assert queue.dequeue().peek() == 'First' and queue.dequeue().peek(
    ) == 'Second'
def test_enqueue_dequeue(my_stack):
    pseudo_q = PseudoQueue(my_stack)
    assert pseudo_q.stack1.peek() == 10
    pseudo_q.enqueue("cat")
    assert pseudo_q.stack1.peek() == "cat"
    pseudo_q.enqueue("dog")
    assert pseudo_q.stack1.peek() == "dog"
    assert pseudo_q.dequeue() == "a"
    assert pseudo_q.stack1.peek() == "dog"
    assert pseudo_q.dequeue() == "b"
    assert pseudo_q.stack1.peek() == "dog"
    assert pseudo_q.dequeue() == "c"
    assert pseudo_q.dequeue() == 10
    assert pseudo_q.dequeue() == "cat"
    assert pseudo_q.dequeue() == "dog"
Beispiel #8
0
def test_enqueue():
    pq = PseudoQueue()
    pq.enqueue('banana')
    pq.enqueue('strawberry')
    pq.enqueue('blueberry')
    expected = 3
    actual = 3
    assert expected == actual
def test_enqueue():
    pseudo = PseudoQueue()
    pseudo.enqueue(20)
    pseudo.enqueue(15)
    pseudo.enqueue(10)
    pseudo.enqueue(5)
    expected = 5
    actual = pseudo.inbox.peek()
    assert actual == expected
Beispiel #10
0
def test_pseudoqueue_dequeue():
    pseudo = PseudoQueue()
    pseudo.enqueue('Portland')
    pseudo.enqueue('Lawrence')
    pseudo.enqueue('Gladstone')
    expected = 'Portland'
    actual = pseudo.dequeue()
    assert expected == actual
def test_pseudoqueue_dequeue_multiple():
    testing_queue = PseudoQueue(Stack())
    testing_queue.enqueue(1)
    testing_queue.enqueue(2)
    testing_queue.dequeue()
    expected = 2
    actual = testing_queue.peek()
    assert actual == expected
def test_enqueue_two():
    queue = PseudoQueue()
    queue.enqueue(Stack())
    queue.front.push('Front')
    queue.enqueue(Stack())
    queue.rear.push('Rear')
    assert queue.front.peek() == 'Front' and queue.rear.peek() == 'Rear'
Beispiel #13
0
def test_pseudoqueue_enqueue_stack_one_many():
    pseudo = PseudoQueue()
    pseudo.enqueue('Portland')
    pseudo.enqueue('Lawrence')
    pseudo.enqueue('Gladstone')
    expected = 'Gladstone'
    actual = pseudo.stack_one.peek()
    assert actual == expected
def test_pseudo_queue_enqueue_one(empty_stack):
    new_queue = PseudoQueue(empty_stack)
    new_queue.enqueue('one')
    assert new_queue.stack_a.peek() == 'one'
def test_pseudo_queue_instance(stack_of_four_nodes):
    assert PseudoQueue(stack_of_four_nodes)
def test_dequeue_empty():
    queue = PseudoQueue()
    with pytest.raises(InvalidOperationError) as error:
        queue.dequeue()
    assert str(error.value) == "Method not allowed on empty queue."
def test_dequeue_empty():
    pseudo_q = PseudoQueue(Stack())
    with pytest.raises(Exception):
        result = pseudo_q.dequeue()
def test_dequeue_one():
    queue = PseudoQueue()
    queue.enqueue(Stack())
    queue.front.push('First')
    assert queue.dequeue().peek() == 'First'
def test_dequeue(my_stack):
    pseudo_q = PseudoQueue(my_stack)
    assert pseudo_q.dequeue() == "a"
def test_enqueue_empty_stack():
    pseudo_q = PseudoQueue(Stack())
    pseudo_q.enqueue("cat")
    assert pseudo_q.stack1.peek() == "cat"
def test_pseudo_queue_dequeue_one(stack_of_four_nodes):
    new_queue = PseudoQueue(stack_of_four_nodes)
    assert new_queue.dequeue() == 1
def pseudo_queue():
    return PseudoQueue()
Beispiel #23
0
def test_PseudoQueue_enqueue():
    element = PseudoQueue()
    element.enqueue(1)
    element.enqueue(2)
    assert element.stack1.peek() == 2
Beispiel #24
0
def test_class_exists():
    PseudoQueue()
Beispiel #25
0
def test_dequeue():
    pq = PseudoQueue()
    pq.enqueue('banana')
    pq.enqueue('strawberry')
    pq.enqueue('blueberry')

    expectedBool = True
    expectedStr = 'banana'
    actualStr, actualBool = pq.dequeue()

    assert expectedBool == actualBool
    assert expectedStr == actualStr

    expectedStr = 'strawberry'
    actualStr, actualBool = pq.dequeue()
    assert expectedStr == actualStr

    # @TODO these next two are failing, I need to move on to LAB tho..

    expectedStr = 'blueberry'
    actualStr, actualBool = pq.dequeue()
    assert expectedStr == actualStr

    expectedStr = ''
    expectedBool = False
    actualStr, actualBool = pq.dequeue()
    assert expectedStr == actualStr
    assert expectedBool == actualBool
Beispiel #26
0
def test_PseudoQueue_dequeue():
    element = PseudoQueue()
    element.enqueue(1)
    element.enqueue(2)
    element.dequeue()
    assert element.stack2.peek() == 2
def test_pseudoqueue_dequeue_none(empty_stack):
    new_queue = PseudoQueue(empty_stack)
    new_queue.dequeue()
    assert new_queue.stack_a.peek() == None
def test_stack1_stack2_exists(my_stack):
    pseudo_q = PseudoQueue(my_stack)
    assert pseudo_q.stack1.peek() == 10
    assert pseudo_q.stack2.peek() == None
Beispiel #29
0
def test_enqueue_one():
    pq = PseudoQueue()
    pq.enqueue("penny")
def test_enqueue(my_stack):
    pseudo_q = PseudoQueue(my_stack)
    pseudo_q.enqueue("cat")
    assert pseudo_q.stack1.peek() == "cat"