def test_self_start_checkout_test() -> None: line = SelfServeLine(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() == 12 assert len(line) == 3 assert line.start_checkout() == 12 assert line.complete_checkout() is True assert line.start_checkout() == 16 assert line.complete_checkout() is True assert line.start_checkout() == 72 assert line.complete_checkout() is False assert line.start_checkout() == 0 assert line.complete_checkout() is False
def test_complete_checkout_no_customer_left() -> None: """check complete with no customer left""" customer1 = Customer("bruce", [Item("banana", 10)]) line1 = RegularLine(3) assert line1.accept(customer1) is True assert line1.complete_checkout() is False line2 = ExpressLine(3) assert line2.accept(customer1) is True assert line2.complete_checkout() is False line3 = SelfServeLine(3) assert line3.accept(customer1) is True assert line3.complete_checkout() is False
def test_complete_checkout_two_people_in_line() -> None: """check for complete checkout with two people in line""" customer1 = Customer("bruce", [Item("banana", 10)]) customer2 = Customer("tom", [Item("banana", 10)]) line1 = RegularLine(3) assert line1.accept(customer1) is True assert line1.accept(customer2) is True assert line1.complete_checkout() is True line2 = ExpressLine(3) assert line2.accept(customer1) is True assert line2.accept(customer2) is True assert line2.complete_checkout() is True line3 = SelfServeLine(3) assert line3.accept(customer1) is True assert line3.accept(customer2) is True assert line3.complete_checkout() is True
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 == []
def test_self_empty_line() -> None: line = SelfServeLine(3) assert line.complete_checkout() is False assert line.start_checkout() == 0