Example #1
0
def test_start_checkout() -> None:
    """Test the start_checkout function of the Checkout Class."""
    a = RegularLine(3)
    b = ExpressLine(3)
    c = SelfServeLine(3)
    c1 = Customer('A', [Item('bananas', 7)])
    c2 = Customer('B', [])
    c3 = Customer('C', [Item('orange', 5)])
    c4 = Customer('D', [Item('grapes', 10), Item('avacado', 1)])
    a.queue = [c1]
    b.queue = [c2, c3]
    c.queue = [c4]
    assert a.start_checkout() == 7
    a.queue = [c1, c2]
    assert a.start_checkout() == 7
    assert b.start_checkout() == 0
    b.queue = [c3]
    assert b.start_checkout() == 5
    assert c.start_checkout() == 22
    c.queue = [c1, c2, c3, c4]
    assert c.start_checkout() == 14
Example #2
0
def test_complete_checkout() -> None:
    """Test the complete_checkout function of the Checkout Class."""
    a = RegularLine(3)
    b = ExpressLine(3)
    c = SelfServeLine(3)
    c1 = Customer('A', [Item('bananas', 7)])
    c2 = Customer('B', [])
    c3 = Customer('C', [Item('orange', 5)])
    c4 = Customer('D', [Item('grapes', 10), Item('avacado', 1)])
    a.queue = [c1]
    b.queue = [c2, c3]
    c.queue = [c4]
    assert a.complete_checkout() == False and a.queue == []
    a.queue = [c2, c1]
    assert a.complete_checkout() == True and a.queue == [c1]
    assert b.complete_checkout() == True and b.queue == [c3]
    assert c.complete_checkout() == False and c.queue == []