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
Exemplo n.º 2
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
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
Exemplo n.º 4
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_express_empty_line() -> None:
    line = ExpressLine(3)
    assert line.complete_checkout() is False
    assert line.start_checkout() == 0