def test_can_successfully_dequeue():
    new_queue = PseudoQueue()
    new_queue.enqueue(5)
    expected = 5
    actual = new_queue.dequeue()

    assert expected == actual
def test_can_successfully_enqueue():
    new_queue = PseudoQueue()
    new_queue.enqueue(5)

    expected = 5
    actual = new_queue.front.nodeVal

    assert expected == actual
def test_dequeue_from_empty():
    pseudo_queue = PseudoQueue()

    expected = "empty stack"

    actual = pseudo_queue.dequeue()

    assert expected == actual
Exemplo n.º 4
0
def test_dequeue():
    pseudo = PseudoQueue()
    pseudo.enqueue(1)
    pseudo.enqueue(2)
    pseudo.enqueue(3)
    pseudo.enqueue(4)
    pseudo.dequeue()
    pseudo.dequeue()
    pseudo.dequeue()
    assert pseudo.stack2.peek() == 4
def test_enqueue():
    pseudo_queue = PseudoQueue()

    for i in range(1, 4):
        pseudo_queue.enqueue(i)

    expected = "1\n2\n3"

    actual = f"{pseudo_queue}"

    assert expected == actual
def test_dequeue_until_empty():
    pseudo = PseudoQueue()
    pseudo.enqueue(1)
    pseudo.enqueue(2)
    pseudo.enqueue(3)
    pseudo.enqueue(4)
    pseudo.dequeue()
    pseudo.dequeue()
    pseudo.dequeue()
    pseudo.dequeue()
    with pytest.raises(AttributeError):
        pseudo.stck1.peek()
Exemplo n.º 7
0
def test_dequeue():
  pq = PseudoQueue()
  pq.enqueue(20)
  pq.enqueue(5)
  pq.enqueue(10)
  pq.enqueue(15)
  actual = pq.dequeue()
  expected = 20
  assert actual == expected
def test_peek_post_dequeue():
    q = PseudoQueue()
    q.enqueue("apples")
    q.enqueue("bananas")
    q.dequeue()
    actual = q.stack1.peek()
    expected = "bananas"
    assert actual == expected
def test_peek():
    q = PseudoQueue()
    q.enqueue("apple")
    q.enqueue("banana")
    q.enqueue("cucumber")
    actual = q.stack1.peek()
    expected = "apple"
    assert actual == expected
def test_enqueue_and_dequeue_many():
    p = PseudoQueue()
    p.enqueue('A')
    p.enqueue('B')
    assert p.dequeue() == 'A'
    p.enqueue('C')
    p.enqueue('D')
    assert p.dequeue() == 'B'
    assert p.dequeue() == 'C'
Exemplo n.º 11
0
def test_enqueue():
  pq = PseudoQueue()
  pq.enqueue(10)
  pq.enqueue(15)
  pq.enqueue(20)
  pq.enqueue(5)
  actual = pq.stack1.top.value
  expected = 5
  assert actual == expected
def test_dequeue_when_full():
    q = PseudoQueue()
    q.enqueue("apples")
    q.enqueue("bananas")
    actual = q.dequeue()
    expected = "apples"
    assert actual == expected
def test_dequeue():
    q = PseudoQueue()
    q.enqueue("apple")
    q.enqueue("banana")
    actual = q.dequeue()
    expected = "apple"
    assert actual == expected
def test_can_successfully_enqueue_multiple_nodes():
    new_queue = PseudoQueue()
    new_queue.enqueue(5)
    new_queue.enqueue(10)
    new_queue.enqueue(15)
    new_queue.enqueue(20)

    expected = 20
    actual = new_queue.front.nodeVal

    assert expected == actual
Exemplo n.º 15
0
def test_dequeue():
    pq = PseudoQueue()
    pq.enqueue(5)
    pq.enqueue(3)
    pq.enqueue(1)
    actual = pq.dequeue()
    expected = 5
    assert actual == expected
def test_enqueue_two():
    q = PseudoQueue()
    q.enqueue("apples")
    q.enqueue("bananas")
    actual = q.stack1.peek()
    expected = "apples"
    assert actual == expected
def test_dequeue():
    pseudo_queue = PseudoQueue()

    pseudo_queue.enqueue("one")
    pseudo_queue.enqueue("two")
    pseudo_queue.enqueue("three")

    pseudo_queue.dequeue()

    expected = "two\nthree"

    actual = f"{pseudo_queue}"

    assert expected == actual
def test_enqueue_2():
    pseudo = PseudoQueue()
    pseudo.enqueue(2)
    pseudo.enqueue(3)
    assert pseudo.stck1.peek() == 2
def test_enqueue_and_dequeue_one():
    p = PseudoQueue()
    p.enqueue('A')
    assert p.dequeue() == 'A'
def test_dequeue_when_empty():
    q = PseudoQueue()
    with pytest.raises(InvalidOperationError):
        q.dequeue()
def test_enqueue():
    q = PseudoQueue()
    q.enqueue("apple")
    actual = q.stack1.top.value
    expected = "apple"
    assert actual == expected
def test_peek_when_empty():
    q = PseudoQueue()
    with pytest.raises(InvalidOperationError):
        q.stack1.peek()
def test_is_empty():
    q = PseudoQueue()
    actual = q.stack1.is_empty()
    expected = True
    assert actual == expected
Exemplo n.º 24
0
def test_enqueue():
    pseudoq = PseudoQueue()
    pseudoq.enqueue(1)
    pseudoq.enqueue(2)
    pseudoq.enqueue(3)
    assert pseudoq.stack2.peek() == 1
def test_enqueue_and_dequeue_all():
    p = PseudoQueue()
    p.enqueue('A')
    p.enqueue('B')
    p.enqueue('C')
    p.enqueue('D')
    p.enqueue('E')
    assert p.dequeue() == 'A'
    assert p.dequeue() == 'B'
    assert p.dequeue() == 'C'
    assert p.dequeue() == 'D'
    assert p.dequeue() == 'E'
    assert p.dequeue() is None
def test_enqueue():
    pseudoq = PseudoQueue()
    pseudoq.enqueue(1)
    assert pseudoq.stck1.peek() == 1
def test_can_successfully_throw_a_dequeue_exception():
    new_queue = PseudoQueue()
    expected = "Exception"
    actual = new_queue.dequeue()
    assert expected == actual
def test_exhausted():
    q = PseudoQueue()
    q.enqueue("apple")
    q.enqueue("banana")
    q.enqueue("cucumber")
    q.dequeue()
    q.dequeue()
    q.dequeue()
    actual = q.stack1.is_empty()
    expected = True
    assert actual == expected
def test_enqueue_one():
    pq = PseudoQueue()
    pq.enqueue("penny")