Пример #1
0
def test_start_checkout_normal_line() -> None:
    """check the checkout for normal line"""
    store1 = GroceryStore(StringIO(CONFIG_FILE2))
    item1 = Item("banana", 10)
    item2 = Item("apple", 2)
    item3 = Item("orange", 9)
    customer1 = Customer("bruce", [item1, item2, item3])
    customer2 = Customer("tom", [item1, item2, item3])
    assert store1.enter_line(customer1) == 0
    assert store1.start_checkout(0) == 21
    assert store1.enter_line(customer2) == 1
    assert store1.start_checkout(1) == 21
Пример #2
0
def test_start_checkout() -> None:
    """Test the start_checkout function of the GroceryStore Class."""
    gs = GroceryStore(StringIO(ONE_LINE_FILE_CONTENTS))
    gs2 = GroceryStore(StringIO(SELF_SERVE_FILE_CONTENTS))
    c1 = Customer('A', [Item('bananas', 7), Item('apple', 2), \
                        Item('orange', 5), Item('grapes', 10)])
    c2 = Customer('B', [Item('apple', 2)])
    c3 = Customer('C', [Item('orange', 5)])
    gs.enter_line(c1)
    gs.enter_line(c2)
    gs2.enter_line(c3)
    assert gs.start_checkout(0) == 24
    assert gs2.start_checkout(0) == 10
def test_start_checkout_non_empty() -> None:
    """ Test whether non empty line starts checkout."""
    store = GroceryStore(GROCERY_STORE)
    item_list = [Item('bananas', 6), Item('apples', 5), Item('carrots', 3)]
    belinda = Customer('Belinda', item_list)
    store.enter_line(belinda)
    assert store.start_checkout(0) == 14
Пример #4
0
def test_start_checkout_self_serve_line() -> None:
    """check for the checkout method for self serve line"""
    store1 = GroceryStore(StringIO(CONFIG_FILE3))
    item1 = Item("banana", 10)
    item2 = Item("apple", 2)
    item3 = Item("orange", 9)
    customer1 = Customer("bruce", [item1, item2, item3])
    assert store1.enter_line(customer1) == 0
    assert store1.start_checkout(0) == 42
def test_line_is_ready_and_close():
    f = StringIO(CONFIG_FILE_100_03)
    store4 = GroceryStore(f)
    customer1 = Customer('b', [Item('a', 29)])
    customer2 = Customer('c', [Item('a', 2)])
    customer3 = Customer('d', [Item('a', 2)])
    store4.enter_line(customer1)
    assert store4.line_is_ready(0)
    store4.enter_line(customer2)
    store4.enter_line(customer3)
    assert len(store4.close_line(0)) == 2
    assert store4.line_is_ready(0)
    assert store4.start_checkout(0) == 29
    assert not store4.complete_checkout(0)
    assert not store4.line_is_ready(0)
def test_start_and_complete_check_out():
    f = StringIO(CONFIG_FILE_111_02)
    store3 = GroceryStore(f)
    lst = []
    for i in range(EXPRESS_LIMIT + 3):
        item = Item('pan', 2)
        lst.append(item)
    customer3 = Customer('a', lst)
    customer4 = Customer('b', [Item('a', 2)])
    customer5 = Customer('c', [Item('a', 20)])
    customer6 = Customer('d', [Item('a', 2)])
    customer9 = Customer('g', [Item('a', 2)])
    lst10 = []
    for i in range(EXPRESS_LIMIT + 2):
        item = Item('pan', 2)
        lst10.append(item)
    customer10 = Customer('h', lst10)
    store3.enter_line(customer4)
    store3.enter_line(customer3)
    store3.enter_line(customer5)
    store3.enter_line(customer6)
    store3.enter_line(customer10)
    store3.enter_line(customer9)
    assert store3.start_checkout(0) == 2
    assert store3.complete_checkout(0)
    assert store3.start_checkout(0) == 2
    assert not store3.complete_checkout(0)
    assert store3.start_checkout(1) == 20
    assert store3.complete_checkout(1)
    assert store3.start_checkout(1) == 2
    assert not store3.complete_checkout(1)
    assert store3.start_checkout(2) == 40
    assert store3.complete_checkout(2)
    assert store3.start_checkout(2) == 36
    assert not store3.complete_checkout(2)
    assert store3.start_checkout(0) == 0
    assert store3.start_checkout(1) == 0
    assert store3.start_checkout(2) == 0
def test_start_checkout_empty() -> None:
    """ Test whether empty line starts checkout."""
    store = GroceryStore(GROCERY_STORE)
    assert store.start_checkout(0) == 0