def test_close_line_people_in_line() -> None: """check close line with people in line""" customer1 = Customer("bruce", []) customer2 = Customer("tom", []) customer3 = Customer("mary", []) line1 = RegularLine(3) assert line1.accept(customer1) is True assert line1.accept(customer2) is True assert line1.accept(customer3) is True assert line1.close() == [customer2, customer3] assert line1.is_open is False assert line1.queue == [customer1] assert line1.can_accept(customer2) is False line2 = ExpressLine(3) assert line2.accept(customer1) is True assert line2.accept(customer2) is True assert line2.accept(customer3) is True assert line2.close() == [customer2, customer3] assert line2.is_open is False assert line2.queue == [customer1] assert line2.can_accept(customer2) is False line3 = SelfServeLine(3) assert line3.accept(customer1) is True assert line3.accept(customer2) is True assert line3.accept(customer3) is True assert line3.close() == [customer2, customer3] assert line3.is_open is False assert line3.queue == [customer1] assert line3.can_accept(customer2) is False
def test_close_line_no_one_in_line() -> None: """check close line with no one in line""" line1 = RegularLine(3) assert line1.close() == [] assert line1.is_open is False line2 = ExpressLine(3) assert line2.close() == [] assert line2.is_open is False line3 = SelfServeLine(3) assert line3.close() == [] assert line3.is_open is False
def test_express_customer_coming_test() -> None: line = ExpressLine(3) lst = [] for i in range(EXPRESS_LIMIT + 1): lst.append(Item("lid", 1)) c1 = Customer("Jameson", lst) c2 = Customer("Jim", [Item("milk", 2), Item("lid", 1), Item("fan", 3)]) c3 = Customer("Jon", [Item("milk", 2), Item("lid", 1), Item("fan", 3)]) c4 = Customer("James", [Item("milk", 2), Item("lid", 1), Item("fan", 3)]) c5 = Customer("Janice", [Item("milk", 2), Item("lid", 1), Item("fan", 3)]) counter = 1 for item in [c1, c2, c3, c4, c5]: if counter == 1: assert not line.can_accept(item) elif item.num_items() <= EXPRESS_LIMIT: assert line.can_accept(item) else: assert not line.can_accept(item) counter += 1 line.close() for item in [c1, c2, c3, c4, c5]: assert not line.can_accept(item)
def test_close_line_one_customer_in_line() -> None: """check close line with one customer in line""" customer1 = Customer("bruce", []) line1 = RegularLine(3) assert line1.accept(customer1) is True assert line1.close() == [] assert line1.is_open is False line2 = ExpressLine(3) assert line2.accept(customer1) is True assert line2.close() == [] assert line2.is_open is False line3 = SelfServeLine(3) assert line3.accept(customer1) is True assert line3.close() == [] assert line3.is_open is False
def test_close() -> None: """Test the close function of the Checkout Class.""" a = RegularLine(3) b = ExpressLine(3) c = SelfServeLine(3) c1 = Customer('A', [Item('bananas', 7)]) c2 = Customer('B', [Item('apple', 2)]) c3 = Customer('C', [Item('orange', 5)]) c4 = Customer('D', [Item('grapes', 10)]) a.queue = [c1] b.queue = [c2, c3, c4] assert a.close() == [] and a.is_open == False assert b.close() == [c3, c4] and a.is_open == False assert c.close() == [] and a.is_open == False assert a.queue == [c1] assert b.queue == [c2] assert c.queue == []
def test_express_close_test() -> None: line = ExpressLine(4) lst = [] lst2 = [] lst3 = [] lst4 = [] lst5 = [] for i in range(EXPRESS_LIMIT): lst.append(Item("lid", 10)) for i in range(EXPRESS_LIMIT): lst2.append(Item("Item_2" + str(i), 1)) for i in range(EXPRESS_LIMIT): lst3.append(Item("Item_3" + str(i), 2)) for i in range(EXPRESS_LIMIT): lst4.append(Item("lid", 100)) counter = 1 c1 = Customer("Jon", lst2) c2 = Customer("James", lst3) c3 = Customer("Janice", lst) c4 = Customer("Johnny", lst4) for item in [c1, c2, c3, c4]: if counter <= 3: assert line.can_accept(item) assert line.accept(item) if counter == 3: assert len(line.queue) == 3 assert line.queue[0] is c1 assert line.queue[1] is c2 assert line.queue[2] is c3 assert line.close() == [c2, c3] assert c1 in line.queue assert len(line.queue) == 1 assert line.queue[0] == c1 if counter > 3: assert not line.can_accept(item) assert not line.accept(item) counter += 1