Ejemplo n.º 1
0
def cart():
    # faking some data (normally would load from DB)
    products = 'celery apples water coffee chicken pizza'.split()
    prices = [1, 4, 2, 5, 6, 4]
    cravings = False, False, False, False, False, True

    items = []
    for item in zip(products, prices, cravings):
        items.append(Item(*item))

    return Groceries(items)
Ejemplo n.º 2
0
def cart():
    """Setup code to create a groceries cart object with 6 items in it"""
    print('sleeping a bit at session level')
    sleep(1)  # for scope=module/session demo purposes
    products = 'celery apples water coffee chicken pizza'.split()
    prices = [1, 4, 2, 5, 6, 4]
    cravings = False, False, False, False, False, True

    items = []
    for item in zip(products, prices, cravings):
        items.append(Item(*item))

    return Groceries(items)
Ejemplo n.º 3
0
def empty_grocery_cart():

    cart = Groceries()

    yield cart
Ejemplo n.º 4
0
def stocked_grocery_cart(items_list):

    cart = Groceries(items_list)

    yield cart
Ejemplo n.º 5
0
def test_initial_empty_cart():
    """Note no fixture here to test an empty cart creation"""
    cart = Groceries()
    assert len(cart) == 0
    assert cart.due == 0