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'
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
コード例 #3
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
コード例 #4
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_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'
コード例 #6
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
コード例 #7
0
def test_pseudoqueue_dequeue_both_stacks_many():
    pseudo = PseudoQueue()
    pseudo.enqueue('Portland')
    pseudo.enqueue('Lawrence')
    pseudo.enqueue('Gladstone')
    pseudo.dequeue()
    pseudo.enqueue('Shawnee Mission')
    pseudo.enqueue('Seattle')
    pseudo.enqueue('Kansas City')
    pseudo.dequeue()
    assert pseudo.stack_one.peek() == 'Kansas City'
コード例 #8
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_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"
コード例 #10
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
コード例 #11
0
def test_enqueue():
    pq = PseudoQueue()
    pq.enqueue('banana')
    pq.enqueue('strawberry')
    pq.enqueue('blueberry')
    expected = 3
    actual = 3
    assert expected == actual
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_enqueue():
    pseudo = PseudoQueue()
    pseudo.enqueue(20)
    pseudo.enqueue(15)
    pseudo.enqueue(10)
    pseudo.enqueue(5)
    expected = 5
    actual = pseudo.inbox.peek()
    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
コード例 #15
0
def test_value():
    queue = PseudoQueue()
    queue.enqueue(2)
    expected = 2
    actual = queue.dequeue()
    assert expected == actual
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_enqueue_empty_stack():
    pseudo_q = PseudoQueue(Stack())
    pseudo_q.enqueue("cat")
    assert pseudo_q.stack1.peek() == "cat"
コード例 #18
0
def test_enqueue(init_stack):
    q = PseudoQueue(init_stack)
    q.enqueue(5)
    assert q.stack.peek() == 5
コード例 #19
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"
def test_enqueue_empty():
    queue = PseudoQueue()
    queue.enqueue(Stack())
    with pytest.raises(InvalidOperationError) as error:
        queue.front.peek()
    assert str(error.value) == "Method not allowed on empty collection."
def test_dequeue_one():
    queue = PseudoQueue()
    queue.enqueue(Stack())
    queue.front.push('First')
    assert queue.dequeue().peek() == 'First'
コード例 #23
0
def test_PseudoQueue_dequeue():
    element = PseudoQueue()
    element.enqueue(1)
    element.enqueue(2)
    element.dequeue()
    assert element.stack2.peek() == 2
コード例 #24
0
def test_PseudoQueue_enqueue():
    element = PseudoQueue()
    element.enqueue(1)
    element.enqueue(2)
    assert element.stack1.peek() == 2
コード例 #25
0
def test_pseudoqueue_enqueue_stack_two_empty():
    pseudo = PseudoQueue()
    pseudo.enqueue('Portland')
    expected = 'Portland'
    actual = pseudo.stack_one.peek()
    assert actual == expected