Exemple #1
0
def test_dequeue_empty_after_multiple_dequeue():
  q = PseudoQueue()
  q.enqueue('monkey')
  q.enqueue('business')
  q.dequeue()
  q.dequeue()
  with pytest.raises(InvalidOperationError) as e:
    q.dequeue()
  assert str(e.value) == 'Method not allowed on an empty collection'
Exemple #2
0
def test_enqueue_first_node():
  q = PseudoQueue()
  q.enqueue('monkey')
  actual1 = q.front.peek()
  expected1 = 'monkey'
  assert actual1 == expected1
  actual2 = q.rear.peek()
  expected2 = 'monkey'
  assert actual2 == expected2
Exemple #3
0
def test_peek_2():
    q = Queue()
    q.enqueue("apple")
    q.enqueue("banana")
    q.enqueue("cucumber")
    actual = q.peek()
    expected = "apple"
    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_peek_post_dequeue():
    q = PseudoQueue()
    q.enqueue("apples")
    q.enqueue("bananas")
    q.dequeue()
    actual = q.stack1.peek()
    expected = "bananas"
    assert actual == expected
def test_dequeue():
    q = PseudoQueue()
    q.enqueue("apple")
    q.enqueue("banana")
    actual = q.dequeue()
    expected = "apple"
    assert actual == expected
def test_dequeue_when_full():
    q = PseudoQueue()
    q.enqueue("apples")
    q.enqueue("bananas")
    actual = q.dequeue()
    expected = "apples"
    assert actual == expected
Exemple #8
0
def test_dequeue_one():
  q = PseudoQueue()
  q.enqueue('monkey')
  q.enqueue('business')
  actual1 = q.dequeue()
  expected1 = 'monkey'
  assert actual1 == expected1
def test_pseudoqueue_enqueue_several():
    q = PseudoQueue()
    q.enqueue("orange")
    q.enqueue("apple")
    actual = q.input.peek()
    expected = "apple"
    assert actual == expected
def queue_test():
    queue = PseudoQueue()
    queue.enqueue(4)
    queue.enqueue(3)
    queue.enqueue(2)
    queue.enqueue(1)
    return queue
def test_enqueue_two():
    q = PseudoQueue()
    q.enqueue("apples")
    q.enqueue("bananas")
    actual = q.stack1.peek()
    expected = "apples"
    assert actual == expected
Exemple #12
0
def test_peek_when_empty():
    q = Queue()
    with pytest.raises(InvalidOperationError):
        q.peek()
Exemple #13
0
def test_enqueue_one():
    q = Queue()
    q.enqueue("apples")
    actual = q.peek()
    expected = "apples"
    assert actual == expected
Exemple #14
0
def test_front_stack_empty():
  q = PseudoQueue()
  assert q.front.top == None
Exemple #15
0
def test_dequeue_empty_on_instantiate():
  q = PseudoQueue()
  with pytest.raises(InvalidOperationError) as e:
    q.dequeue
  assert str(e.value) == 'Method not allowed on an empty collection'
Exemple #16
0
def test_enqueue_two():
  q = PseudoQueue()
  q.enqueue('monkey')
  q.enqueue('business')
  assert q.front.peek() == 'monkey'
  assert q.rear.peek() == 'business'
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
Exemple #18
0
def test_enqueue():
    q = Queue()
    q.enqueue("apple")
    actual = q.front.value
    expected = "apple"
    assert actual == expected
def test_pseudoqueue_dequeue_one():
    q = PseudoQueue()
    q.enqueue("orange")
    actual = q.dequeue()
    expected = "orange"
    assert actual == expected
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_pseudoqueue_dequeue_several():
    q = PseudoQueue()
    q.enqueue("orange")
    q.enqueue("apple")
    q.enqueue("lime")
    q.dequeue()
    q.dequeue()
    actual = q.dequeue()
    expected = "orange"
    assert actual == expected
def test_is_empty():
    q = PseudoQueue()
    actual = q.stack1.is_empty()
    expected = True
    assert actual == expected
def test_queue_enqueue():
    expected = "5"
    queue = PseudoQueue()
    queue.enqueue(5)
    actual = f"{queue}"
    assert actual == expected
Exemple #26
0
def test_is_empty():
    q = Queue()
    actual = q.is_empty()
    expected = True
    assert actual == expected