コード例 #1
0
def test_line_is_ready() -> None:
    """check the method of line is ready"""
    store1 = GroceryStore(StringIO(CONFIG_FILE2))
    customer1 = Customer("bruce", [])
    assert store1.line_is_ready(0) is False
    assert store1.line_is_ready(1) is False
    assert store1.enter_line(customer1) == 0
    assert store1.line_is_ready(0) is True
    assert store1.line_is_ready(1) is False
コード例 #2
0
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)
コード例 #3
0
def test_line_is_ready_one_occupant() -> None:
    """ Test line is ready with exactly one customer."""
    store = GroceryStore(GROCERY_STORE)
    item_list = [Item('bananas', 6)]
    belinda = Customer('Belinda', item_list)
    store.enter_line(belinda)
    assert store.line_is_ready(0)
コード例 #4
0
def test_line_is_ready() -> None:
    """Test the line_is_ready function of the GroceryStore Class."""
    gs = GroceryStore(StringIO(SHORT_FILE_CONTENTS))
    gs2 = GroceryStore(StringIO(SHORT_FILE_CONTENTS))
    c1 = Customer('A', [Item('bananas', 7)])
    c2 = Customer('B', [Item('apple', 2)])
    c3 = Customer('C', [Item('orange', 5)])
    c4 = Customer('D', [Item('grapes', 10)])
    gs.enter_line(c1)
    gs.enter_line(c2)
    gs.enter_line(c3)
    gs.enter_line(c4)
    assert gs.line_is_ready(0) == False
    assert gs.line_is_ready(1) == True
    assert gs.line_is_ready(2) == True
    assert gs2.line_is_ready(0) == False
    assert gs2.line_is_ready(1) == False
    assert gs2.line_is_ready(2) == False
コード例 #5
0
def test_is_ready_more_occupants() -> None:
    """ Test line is ready with more than one customer."""
    store = GroceryStore(GROCERY_STORE_1_LINE_2_CAP)
    item_list = [Item('bananas', 6)]
    belinda = Customer('Belinda', item_list)
    item_list_2 = [Item('apples', 5)]
    arnold = Customer('Arnold', item_list_2)
    store.enter_line(belinda)
    store.enter_line(arnold)
    assert not store.line_is_ready(0)
コード例 #6
0
def test_line_is_ready_empty_line() -> None:
    """ Test line is ready with no customers."""
    store = GroceryStore(GROCERY_STORE)
    assert not store.line_is_ready(0)