def test_start_checkout_non_empty() -> None:
    """ Test how many customers are left when a line with a customer
    starts checkout."""
    line = RegularLine(1)
    item_list = [Item('bananas', 1), Item('apples', 2), Item('kiwis', 3)]
    jeff = Customer('Jeff', item_list)
    line.accept(jeff)
    assert line.start_checkout() == 6
def test_regular_start_checkout_test() -> None:
    line = RegularLine(3)
    c1 = Customer("John", [Item("milk", 2), Item("lid", 1), Item("fan", 3)])
    c2 = Customer("Jim", [Item("milk", 2), Item("lid", 1), Item("fan", 5)])
    c3 = Customer("James", [Item("milk", 2), Item("lid", 1), Item("fan", 33)])
    c4 = Customer("Janice", [Item("milk", 2), Item("lid", 1), Item("fan", 23)])
    for item in [c1, c2, c3, c4]:
        if line.can_accept(item):
            line.accept(item)
    assert line.start_checkout() == 6
    assert len(line) == 3
    assert line.start_checkout() == 6
    assert line.complete_checkout() is True
    assert line.start_checkout() == 8
    assert line.complete_checkout() is True
    assert line.start_checkout() == 36
    assert line.complete_checkout() is False
    assert line.start_checkout() == 0
    assert line.complete_checkout() is False
def test_start_checkout_two_in_line() -> None:
    """ Test how many customers are left when a line with more than one customer
    starts checkout."""
    line = RegularLine(2)
    item_list = [Item('bananas', 1), Item('bananas', 1)]
    jeff = Customer('Jeff', item_list)
    item_list_2 = [Item('bananas', 1), Item('bananas', 1)]
    sofia = Customer('Sofia', item_list_2)
    line.accept(jeff)
    line.accept(sofia)
    assert line.start_checkout() == 2
Exemplo n.º 4
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
Exemplo n.º 5
0
def test_regular_line_checkout_started() -> None:
    """check checkout started for regular line and express line"""
    customer1 = Customer("bruce", [
        Item("banana", 10),
        Item("banana", 10),
        Item("banana", 10),
        Item("banana", 10),
        Item("banana", 10),
        Item("banana", 10),
        Item("banana", 10),
        Item("banana", 10),
        Item("banana", 10)
    ])
    customer2 = Customer("tom", [Item("banana", 10), Item("banana", 10)])
    line1 = RegularLine(3)
    assert line1.accept(customer1) is True
    assert line1.accept(customer2) is True
    assert line1.start_checkout() == 90
    line2 = ExpressLine(3)
    assert line2.accept(customer1) is False
    assert line2.accept(customer2) is True
    assert line2.start_checkout() == 20
def test_regular_empty_line() -> None:
    line = RegularLine(3)
    assert line.complete_checkout() is False
    assert line.start_checkout() == 0
def test_start_checkout_empty() -> None:
    """ Test how many customers are left when an empty line starts checkout."""
    line = RegularLine(1)
    assert line.start_checkout() == 0