def test_express_normal_test_for_close_test() -> None:
    line = ExpressLine(2)
    lst = []
    lst2 = []
    lst3 = []
    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))

    c1 = Customer("Jon", lst2)
    c2 = Customer("James", lst3)
    c3 = Customer("Janice", lst)
    for item in [c1, c2, c3]:
        line.accept(item)
    assert len(line.queue) == line.capacity
    assert line.capacity == 2
    assert line.queue[0] is c1
    assert line.queue[1] is c2
    assert line.start_checkout() == EXPRESS_LIMIT
    assert line.complete_checkout() is True
    assert line.start_checkout() == EXPRESS_LIMIT * 2
    assert line.complete_checkout() is False
    assert line.start_checkout() == 0
    assert len(line) == 0
    assert len(line.queue) == 0
    assert line.complete_checkout() is False
Пример #2
0
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_express_start_checkout_test() -> None:
    line = ExpressLine(3)
    lst = []
    lst2 = []
    lst3 = []
    for i in range(EXPRESS_LIMIT + 1):
        lst.append(Item("lid", 1))
    for i in range(EXPRESS_LIMIT - 1):
        lst2.append(Item("Item_2" + str(i), 1))
    for i in range(EXPRESS_LIMIT):
        lst3.append(Item("Item_3" + str(i), 2))

    c1 = Customer("Jon", lst2)
    c2 = Customer("James", lst3)
    c3 = Customer("Janice", lst)
    counter = 1
    for item in [c1, c2, c3]:
        if counter in (1, 2):
            assert line.can_accept(item)
            assert line.accept(item)
        else:
            assert not line.can_accept(item)
            assert not line.accept(item)
        counter += 1
    assert len(line.queue) == 2
    assert line.capacity == 3
    assert line.queue[0] is c1
    assert line.queue[1] is c2
    assert line.start_checkout() == EXPRESS_LIMIT - 1
    assert len(line) == 2
    assert line.start_checkout() == EXPRESS_LIMIT - 1
    assert line.complete_checkout() is True
    assert line.start_checkout() == 2 * EXPRESS_LIMIT
    assert line.complete_checkout() is False
    assert line.start_checkout() == 0
    assert len(line) == 0
    assert len(line.queue) == 0
    assert line.complete_checkout() is False
Пример #4
0
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
Пример #5
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 == []
def test_express_empty_line() -> None:
    line = ExpressLine(3)
    assert line.complete_checkout() is False
    assert line.start_checkout() == 0