コード例 #1
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_empty_sides_update_inventory(gourmet_fixture):
    print("~~~~~~~~~~~ checkout empty side ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    mains = []
    mains.append(main)

    order_ID = system.checkout(mains, None, drink, inv)
    assert (len(system._curr_orders) == 1)
    order = system.get_curr_order_by_ID(order_ID)

    main_ingredient = order.mains[0].ingredients
    assert main_ingredient['Sesame bun'] == 2
    assert main_ingredient['Chicken patty'] == 1
    assert main_ingredient['Tomato'] == 1
    assert main_ingredient['Cheddar cheese'] == 1

    drink_ingredient = order.drinks.ingredients
    assert drink_ingredient['Mtn Dew'] == 1
    assert drink_ingredient['Baijiu'] == 1
    assert drink_ingredient['Whiskey'] == 1

    order.print_order(inv)
コード例 #2
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_empty_sides(gourmet_fixture):
    print("~~~~~~~~~~~ checkout empty side ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    mains = []
    mains.append(main)

    system.checkout(mains, None, drink, inv)
    assert gourmet_fixture.get_stock_quantity('Sesame bun') == 8
    assert gourmet_fixture.get_stock_quantity('Chicken patty') == 19
    assert gourmet_fixture.get_stock_quantity('Tomato') == 68
    assert gourmet_fixture.get_stock_quantity('Cheddar cheese') == 68
    assert gourmet_fixture.get_stock_quantity('Mtn dew') == 10
    assert gourmet_fixture.get_stock_quantity('Baijiu') == 10
    assert gourmet_fixture.get_stock_quantity('Whiskey') == 10
コード例 #3
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_basic_inventory_update(gourmet_fixture):
    print("~~~~~~~~~~~ checkout basic ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('small fries').name] = 2

    drink = {}
    drink[inv.get_ingredient('cokain').name] = 2
    drink[inv.get_ingredient('sake').name] = 1

    mains = []
    mains.append(main)

    system.checkout(mains, side, drink, inv)
    # assert(inv.food_dict[item] == [insert number here])
    # check quantity left in inventory after checking out
    assert gourmet_fixture.get_stock_quantity('Sesame bun') == 8
    assert gourmet_fixture.get_stock_quantity('Chicken patty') == 19
    assert gourmet_fixture.get_stock_quantity('Tomato') == 68
    assert gourmet_fixture.get_stock_quantity('Cheddar cheese') == 68
    assert gourmet_fixture.get_stock_quantity('6 pack nuggets') == 98
    assert gourmet_fixture.get_stock_quantity('Small fries') == 95
    assert gourmet_fixture.get_stock_quantity('Cokain') == 9
    assert gourmet_fixture.get_stock_quantity('Sake') == 10
コード例 #4
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_empty_drinks(gourmet_fixture):
    print("~~~~~~~~~~~ checkout empty drinks ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1
    side[inv.get_ingredient('wiked wingz').name] = 1

    mains = []
    mains.append(main)

    order_ID = system.checkout(mains, side, None, inv)
    assert (len(system._curr_orders) == 1)
    order = system.get_curr_order_by_ID(order_ID)
    main_ingredient = order.mains[0].ingredients
    assert main_ingredient['Sesame bun'] == 2
    assert main_ingredient['Chicken patty'] == 1
    assert main_ingredient['Tomato'] == 1
    assert main_ingredient['Cheddar cheese'] == 1

    side_ingredient = order.sides.ingredients
    assert side_ingredient['6 pack nuggets'] == 1
    assert side_ingredient['Large fries'] == 1
    assert side_ingredient['Wiked wingz'] == 1

    order.print_order(inv)
コード例 #5
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_exception_all_empty(gourmet_fixture):
    print("~~~~~~~~~~~ checkout all empty ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()
    with pytest.raises(OrderError) as e:
        system.checkout(None, None, None, inv)
    assert str(e.value) == "Invalid order, please add in a main/side/drink.\n"
コード例 #6
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_empty_drinks_update_inventory(gourmet_fixture):
    print("~~~~~~~~~~~ checkout empty side ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1
    side[inv.get_ingredient('wiked wingz').name] = 1

    mains = []
    mains.append(main)

    system.checkout(mains, side, None, inv)
    assert gourmet_fixture.get_stock_quantity('Sesame bun') == 8
    assert gourmet_fixture.get_stock_quantity('Chicken patty') == 19
    assert gourmet_fixture.get_stock_quantity('Tomato') == 68
    assert gourmet_fixture.get_stock_quantity('Cheddar cheese') == 68
    assert gourmet_fixture.get_stock_quantity('6 pack nuggets') == 98
    assert gourmet_fixture.get_stock_quantity('Large fries') == 98
    assert gourmet_fixture.get_stock_quantity('Wiked Wingz') == 98
コード例 #7
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_exception_empty_inventory(gourmet_fixture):
    print("~~~~~~~~~~~ checkout all empty ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1
    side[inv.get_ingredient('wiked wingz').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    mains = []
    mains.append(main)

    with pytest.raises(OrderError) as e:
        system.checkout(mains, side, drink, None)
    assert str(e.value) == "Invalid Inventory specified.\n"
コード例 #8
0
def test_make_main_order(gourmet_fixture):
    print("\n~~~~~~~~~ test making order ~~~~~~~~~~~~~~")
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    order = system.create_order(ID)

    main_one = {}
    print("adding 2 sesame bun")
    main_one[inv.get_ingredient('sesame bun').name] = 2
    print("adding chicken patty")
    main_one[inv.get_ingredient('chicken patty').name] = 1
    print("adding tomato")
    main_one[inv.get_ingredient('tomato').name] = 1
    print("adding Cheddar cheese\n")
    main_one[inv.get_ingredient('cheddar cheese').name] = 1
    system.add_to_order(ID, main_one, inv)

    print("printing out order after adding main number one")
    order.print_order(inv)
    assert order.calculate_order_price(inv) == 12.36
    main_one_ingredients = order.mains[0].ingredients
    assert main_one_ingredients['Sesame bun'] == 2
    assert main_one_ingredients['Chicken patty'] == 1
    assert main_one_ingredients['Tomato'] == 1
    assert main_one_ingredients['Cheddar cheese'] == 1
コード例 #9
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_empty_mains(gourmet_fixture):
    print("~~~~~~~~~~~ checkout empty side ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1
    side[inv.get_ingredient('wiked wingz').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    order_ID = system.checkout(None, side, drink, inv)
    assert (len(system._curr_orders) == 1)
    order = system.get_curr_order_by_ID(order_ID)
    side_ingredient = order.sides.ingredients
    assert side_ingredient['6 pack nuggets'] == 1
    assert side_ingredient['Large fries'] == 1
    assert side_ingredient['Wiked wingz'] == 1

    drink_ingredient = order.drinks.ingredients
    assert drink_ingredient['Mtn Dew'] == 1
    assert drink_ingredient['Baijiu'] == 1
    assert drink_ingredient['Whiskey'] == 1
    order.print_order(inv)
コード例 #10
0
def myCart():
    global newOrder

    if newOrder == 0:
        return redirect(url_for('home'))

    f = open("stock.pickle", "rb")
    inventory = pickle.load(f)
    f.close

    f = open("temp_order.pickle", "rb")
    order = pickle.load(f)
    f.close()

    f = open("system.pickle", "rb")
    try:
        system = pickle.load(f)
    except EOFError:
        f.close()
        system = OrderingSystem()
    finally:
        print(newOrder)
        if request.method == "POST":
            if request.form.get("Cancel Order") != None:
                newOrder = 0
                return redirect(url_for('home'))
            else:
                try:
                    ID = system.checkout(order[0], order[1], order[2],
                                         inventory)
                except OrderError as error:
                    return render_template('my_cart.html',
                                           order=order,
                                           inventory=inventory,
                                           error=error)
                else:
                    newOrder = 0
                    f = open("system.pickle", "wb")
                    pickle.dump(system, f)
                    f = open("stock.pickle", "wb")
                    pickle.dump(inventory, f)
                    f.close
                    return redirect(url_for('myOrder', orderID=ID))

    # price calculating logic
    price = 0
    total = {}
    for main in order[0]:
        total = merge_dictonaries(total, main)
    total = merge_dictonaries(total, order[1])
    total = merge_dictonaries(total, order[2])
    for key in total:
        stock = inventory.get_ingredient(key)
        price = price + stock.price * total[key]

    return render_template('my_cart.html',
                           order=order,
                           inventory=inventory,
                           price=price)
コード例 #11
0
def test_checkout_all_empty(gourmet_fixture):
    print("~~~~~~~~~~~ checkout all empty ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()
    side = {}
    drink = {}
    mains = []
    with pytest.raises(OrderError) as e:
        system.checkout(mains, side, drink, inv)
    assert str(e.value) == "Invalid order, please add in a main/side/drink.\n"
コード例 #12
0
def test_empty_order(gourmet_fixture):
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    system.create_order(ID)

    main = {}

    order = system.add_to_order(ID, main, inv)
    assert order == None
コード例 #13
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_two_main(gourmet_fixture):
    print("~~~~~~~~~~~ checkout two main ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    main_two = {}
    main_two[inv.get_ingredient('Mad bun').name] = 2
    main_two[inv.get_ingredient('beef patty').name] = 2
    main_two[inv.get_ingredient('lettuce').name] = 3
    main_two[inv.get_ingredient('Swiss cheese').name] = 5

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('small fries').name] = 2

    drink = {}
    drink[inv.get_ingredient('cokain').name] = 2
    drink[inv.get_ingredient('sake').name] = 1

    mains = []
    mains.append(main)
    mains.append(main_two)

    order_ID = system.checkout(mains, side, drink, inv)
    # assert(inv.food_dict[item] == [insert number here])
    order = system.get_curr_order_by_ID(order_ID)
    main_ingredient = order.mains[0].ingredients
    assert main_ingredient['Sesame bun'] == 2
    assert main_ingredient['Chicken patty'] == 1
    assert main_ingredient['Tomato'] == 1
    assert main_ingredient['Cheddar cheese'] == 1

    main_ingredient = order.mains[1].ingredients
    assert main_ingredient['Mad bun'] == 2
    assert main_ingredient['Beef patty'] == 2
    assert main_ingredient['Lettuce'] == 3
    assert main_ingredient['Swiss Cheese'] == 5

    side_ingredient = order.sides.ingredients
    assert side_ingredient['6 pack nuggets'] == 1
    assert side_ingredient['Small fries'] == 2

    drink_ingredient = order.drinks.ingredients
    assert drink_ingredient['Cokain'] == 2
    assert drink_ingredient['Sake'] == 1
    order.print_order(inv)
コード例 #14
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_all_empty(gourmet_fixture):
    print("~~~~~~~~~~~ checkout all empty ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    side = {}
    drink = {}

    mains = []
    mains.append(main)

    system.checkout(mains, side, drink, inv)
コード例 #15
0
def test_addto_drink(gourmet_fixture):
    print("\n ~~~~~~~ test addto drink order ~~~~~~~~~~~~~")
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    order = system.create_order(ID)

    drink = {}
    print("adding 2 cokain")
    drink[inv.get_ingredient('cokain').name] = 2
    # what kind of burger joint serves sake
    print("adding sake")
    drink[inv.get_ingredient('sake').name] = 1
    system.add_to_order(ID, drink, inv)
    print("printing out order after adding drink\n")
    order.print_order(inv)

    print("adding another 2 cokain")
    drink = {}
    drink[inv.get_ingredient('cokain').name] = 2
    # what kind of burger joint serves sake
    system.add_to_order(ID, drink, inv)
    print("printing out order after adding 2nd batch of drinks\n")
    order.print_order(inv)
    # testing the list of ingredients in drinks
    drink_ingredient = order.drinks.ingredients
    assert drink_ingredient['Sake'] == 1
    assert drink_ingredient['Cokain'] == 4
    assert(order.calculate_order_price(inv) == 345)
コード例 #16
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_two_main_inventory_update(gourmet_fixture):
    print("~~~~~~~~~~~ checkout two main ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    main_two = {}
    main_two[inv.get_ingredient('Mad bun').name] = 2
    main_two[inv.get_ingredient('beef patty').name] = 2
    main_two[inv.get_ingredient('lettuce').name] = 3
    main_two[inv.get_ingredient('Swiss cheese').name] = 5

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('small fries').name] = 2

    drink = {}
    drink[inv.get_ingredient('cokain').name] = 2
    drink[inv.get_ingredient('sake').name] = 1

    mains = []
    mains.append(main)
    mains.append(main_two)

    system.checkout(mains, side, drink, inv)
    assert gourmet_fixture.get_stock_quantity('Sesame bun') == 8
    assert gourmet_fixture.get_stock_quantity('Chicken patty') == 19
    assert gourmet_fixture.get_stock_quantity('Tomato') == 68
    assert gourmet_fixture.get_stock_quantity('Cheddar cheese') == 68
    assert gourmet_fixture.get_stock_quantity('Mad bun') == 8
    assert gourmet_fixture.get_stock_quantity('Beef patty') == 18
    assert gourmet_fixture.get_stock_quantity('Lettuce') == 66
    assert gourmet_fixture.get_stock_quantity('Swiss Cheese') == 64
    assert gourmet_fixture.get_stock_quantity('6 pack nuggets') == 98
    assert gourmet_fixture.get_stock_quantity('Small fries') == 95
    assert gourmet_fixture.get_stock_quantity('Cokain') == 9
    assert gourmet_fixture.get_stock_quantity('Sake') == 10
コード例 #17
0
def test_add_side(gourmet_fixture):
    print("\n~~~~~~~~~ test make side order~~~~~~~~~~~~~~")
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    order = system.create_order(ID)

    side = {}
    print("adding chicken nuggests 6")
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    print("adding 2 small fries")
    side[inv.get_ingredient('small fries').name] = 2
    system.add_to_order(ID, side, inv)
    print("printing out order after adding side")
    order.print_order(inv)

    side = order.sides.ingredients
    assert side['6 pack nuggets'] == 1
    assert side['Small fries'] == 2
    assert(round(order.calculate_order_price(inv),2) == 12.6)
コード例 #18
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_empty_mains_update_inventory(gourmet_fixture):
    print("~~~~~~~~~~~ checkout empty side ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1
    side[inv.get_ingredient('wiked wingz').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    system.checkout(None, side, drink, inv)
    assert gourmet_fixture.get_stock_quantity('6 pack nuggets') == 98
    assert gourmet_fixture.get_stock_quantity('Large fries') == 98
    assert gourmet_fixture.get_stock_quantity('Wiked Wingz') == 98
    assert gourmet_fixture.get_stock_quantity('Mtn dew') == 10
    assert gourmet_fixture.get_stock_quantity('Baijiu') == 10
    assert gourmet_fixture.get_stock_quantity('Whiskey') == 10
コード例 #19
0
def test_less_than_min(gourmet_fixture):
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    system.create_order(ID)

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 1

    with pytest.raises(OrderError) as e:
        system.add_to_order(ID, main, inv)
    assert str(e.value) == 'Minimum ordering limit for bun is 2.\n'
コード例 #20
0
def test_exceed_max_different_bun(gourmet_fixture):
    print("\n ~~~~~~~ test exceed max ~~~~~~~~~~~~~")
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    system.create_order(ID)

    main = {}
    main[inv.get_ingredient('Sesame bun').name] = 2
    main[inv.get_ingredient('Mad bun').name] = 3

    with pytest.raises(OrderError) as e:
        system.add_to_order(ID, main, inv)
    assert str(e.value) == 'Maximum ordering limit for bun is 4.\n'
コード例 #21
0
def test_exceed_inventory(gourmet_fixture):
    print("\n ~~~~~~~ test exceed inventory ~~~~~~~~~~~~~")
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    system.create_order(ID)

    side = {}
    print("I want 200 fries cause imma fatty")
    # there is only 101 fries in inventory
    side[inv.get_ingredient('large fries').name] = 200
    with pytest.raises(OrderError) as e:
        system.add_to_order(ID, side, inv)
    assert str(e.value) == 'Order exceeds inventory: Only 101 of Large fries left in inventory.\n'
コード例 #22
0
def test_item_not_in_inv(gourmet_fixture):
    print("\n ~~~~~~~ test items not in system ~~~~~~~~~~~~~")
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    system.create_order(ID)

    drink = {}
    print("I wanna order a yeet")
    drink["yeet"] = 1
    print("I wanna order a xd")
    drink["xd"] = 1

    print("adding above to order number 1")
    with pytest.raises(OrderError) as e:
        system.add_to_order(ID, drink, inv)
    assert str(e.value) == "We do not serve 'yeet', please specify a valid item.\nWe do not serve 'xd', please specify a valid item.\n"
コード例 #23
0
def test_exceed_max_patty(gourmet_fixture):
    print("\n ~~~~~~~ test exceed max ~~~~~~~~~~~~~")
    inv = gourmet_fixture
    IDgen = IdGenerator(0)
    ID = IDgen.next()
    system = OrderingSystem()
    system.create_order(ID)

    main = {}

    print("adding wrap")
    main[inv.get_ingredient('wrap').name] = 1
    print("I want 5 beef patty in my burger")
    main[inv.get_ingredient('beef patty').name] = 5 

    with pytest.raises(OrderError) as e:
        system.add_to_order(ID, main, inv)
    assert str(e.value) == 'Maximum ordering limit for patty is 3.\n'
コード例 #24
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_multiple_orders(gourmet_fixture):
    print("~~~~~~~~~~~ checkout multiple orders ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('small fries').name] = 2

    mains = []
    mains.append(main)

    order_ID = system.checkout(mains, side, None, inv)
    assert (len(system._curr_orders) == 1)
    assert order_ID == 0
    order = system.get_curr_order_by_ID(order_ID)
    main_ingredient = order.mains[0].ingredients
    assert main_ingredient['Sesame bun'] == 2
    assert main_ingredient['Chicken patty'] == 1
    assert main_ingredient['Tomato'] == 1
    assert main_ingredient['Cheddar cheese'] == 1

    side_ingredient = order.sides.ingredients
    assert side_ingredient['6 pack nuggets'] == 1
    assert side_ingredient['Small fries'] == 2
    order.print_order(inv)

    main = {}
    main[inv.get_ingredient('wrap').name] = 1
    main[inv.get_ingredient('vegetarian patty').name] = 1
    main[inv.get_ingredient('tomato sauce').name] = 1
    main[inv.get_ingredient('lettuce').name] = 1
    main[inv.get_ingredient('tomato').name] = 1

    drink = {}
    drink[inv.get_ingredient('vodka').name] = 1

    mains = []
    mains.append(main)

    order_ID = system.checkout(mains, None, drink, inv)
    assert (len(system._curr_orders) == 2)
    assert order_ID == 1
    order = system.get_curr_order_by_ID(order_ID)
    main_ingredient = order.mains[0].ingredients
    assert main_ingredient['Wrap'] == 1
    assert main_ingredient['Vegetarian patty'] == 1
    assert main_ingredient['Lettuce'] == 1
    assert main_ingredient['Tomato'] == 1

    drink_ingredient = order.drinks.ingredients
    assert drink_ingredient['Vodka'] == 1
    order.print_order(inv)

    main = {}
    main[inv.get_ingredient('burnt bun').name] = 3
    main[inv.get_ingredient('tomato sauce').name] = 5

    mains = []
    mains.append(main)

    order_ID = system.checkout(mains, '', '', inv)
    assert (len(system._curr_orders) == 3)

    order = system.get_curr_order_by_ID(order_ID)
    main_ingredient = order.mains[0].ingredients
    assert main_ingredient['Burnt bun'] == 3
    assert main_ingredient['Tomato sauce'] == 5
    order.print_order(inv)

    main = {}
    main[inv.get_ingredient('muffin bun').name] = 3
    main[inv.get_ingredient('Vegetarian patty').name] = 1
    main[inv.get_ingredient('beef patty').name] = 1
    main[inv.get_ingredient('tomato sauce').name] = 1
    main[inv.get_ingredient('tomato').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1
    side[inv.get_ingredient('wiked wingz').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    mains = []
    mains.append(main)

    order_ID = system.checkout(mains, side, drink, inv)
    assert (len(system._curr_orders) == 4)

    order = system.get_curr_order_by_ID(order_ID)
    main_ingredient = order.mains[0].ingredients
    assert main_ingredient['Muffin bun'] == 3
    assert main_ingredient['Vegetarian patty'] == 1
    assert main_ingredient['Beef patty'] == 1
    assert main_ingredient['Tomato sauce'] == 1
    assert main_ingredient['Tomato'] == 1

    side_ingredient = order.sides.ingredients
    assert side_ingredient['6 pack nuggets'] == 1
    assert side_ingredient['Large fries'] == 1
    assert side_ingredient['Wiked wingz'] == 1

    drink_ingredient = order.drinks.ingredients
    assert drink_ingredient['Mtn Dew'] == 1
    assert drink_ingredient['Baijiu'] == 1
    assert drink_ingredient['Whiskey'] == 1

    order.print_order(inv)
コード例 #25
0
ファイル: test02.py プロジェクト: metallicOxide/BurgerWebsite
def test_checkout_multiple_orders_update_inventory(gourmet_fixture):
    print("~~~~~~~~~~~ checkout two mains ~~~~~~~~~~~~")
    inv = gourmet_fixture
    system = OrderingSystem()

    # order number 1
    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
    main[inv.get_ingredient('Cheddar cheese').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('small fries').name] = 2

    mains = []
    mains.append(main)

    system.checkout(mains, side, None, inv)
    assert gourmet_fixture.get_stock_quantity('Sesame bun') == 8
    assert gourmet_fixture.get_stock_quantity('Chicken patty') == 19
    assert gourmet_fixture.get_stock_quantity('Tomato') == 68
    assert gourmet_fixture.get_stock_quantity('Cheddar cheese') == 68
    assert gourmet_fixture.get_stock_quantity('6 pack nuggets') == 98
    assert gourmet_fixture.get_stock_quantity('Small fries') == 95

    # order number 2
    main = {}
    main[inv.get_ingredient('wrap').name] = 1
    main[inv.get_ingredient('vegetarian patty').name] = 1
    main[inv.get_ingredient('tomato sauce').name] = 1
    main[inv.get_ingredient('lettuce').name] = 1
    main[inv.get_ingredient('tomato').name] = 1

    drink = {}
    drink[inv.get_ingredient('vodka').name] = 1

    mains = []
    mains.append(main)

    system.checkout(mains, None, drink, inv)
    assert gourmet_fixture.get_stock_quantity('Wrap') == 11
    assert gourmet_fixture.get_stock_quantity('Vegetarian patty') == 19
    assert gourmet_fixture.get_stock_quantity('Tomato sauce') == 68
    assert gourmet_fixture.get_stock_quantity('Lettuce') == 68
    assert gourmet_fixture.get_stock_quantity('Tomato') == 67
    assert gourmet_fixture.get_stock_quantity('Vodka') == 10

    # order number 3
    main = {}
    main[inv.get_ingredient('burnt bun').name] = 3
    main[inv.get_ingredient('tomato sauce').name] = 5

    mains = []
    mains.append(main)

    system.checkout(mains, '', '', inv)
    assert gourmet_fixture.get_stock_quantity('Tomato sauce') == 63
    assert gourmet_fixture.get_stock_quantity('Burnt bun') == 7

    # order number 4
    main = {}
    main[inv.get_ingredient('muffin bun').name] = 3
    main[inv.get_ingredient('Vegetarian patty').name] = 1
    main[inv.get_ingredient('beef patty').name] = 1
    main[inv.get_ingredient('tomato sauce').name] = 1
    main[inv.get_ingredient('tomato').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1
    side[inv.get_ingredient('wiked wingz').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    mains = []
    mains.append(main)

    system.checkout(mains, side, drink, inv)
    assert gourmet_fixture.get_stock_quantity('Muffin bun') == 7
    assert gourmet_fixture.get_stock_quantity('Vegetarian patty') == 18
    assert gourmet_fixture.get_stock_quantity('Beef patty') == 19
    assert gourmet_fixture.get_stock_quantity('Tomato sauce') == 62
    assert gourmet_fixture.get_stock_quantity('Tomato') == 66

    assert gourmet_fixture.get_stock_quantity('6 pack nuggets') == 95
    assert gourmet_fixture.get_stock_quantity('Large fries') == 98
    assert gourmet_fixture.get_stock_quantity('Wiked Wingz') == 98

    assert gourmet_fixture.get_stock_quantity('Mtn dew') == 10
    assert gourmet_fixture.get_stock_quantity('Baijiu') == 10
    assert gourmet_fixture.get_stock_quantity('Whiskey') == 10
コード例 #26
0
def order_fixture(gourmet_fixture):
    inv = gourmet_fixture
    system = OrderingSystem()

    # ORDER 1
    main = {}
    main[inv.get_ingredient('sesame bun').name] = 2
    main[inv.get_ingredient('chicken patty').name] = 1
    main[inv.get_ingredient('tomato').name] = 1 
    main[inv.get_ingredient('Cheddar cheese').name] = 1 

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('small fries').name] = 2

    mains = []
    mains.append(main)
    system.checkout(mains, side, None, inv)

    # ORDER 2
    main = {}
    main[inv.get_ingredient('wrap').name] = 1 
    main[inv.get_ingredient('vegetarian patty').name] = 1 
    main[inv.get_ingredient('tomato sauce').name] = 1
    main[inv.get_ingredient('lettuce').name] = 1
    main[inv.get_ingredient('tomato').name] = 1

    drink = {}
    drink[inv.get_ingredient('vodka').name] = 1 

    mains = []
    mains.append(main)

    system.checkout(mains, None, drink, inv)

    # ORDER 3
    main = {}
    main[inv.get_ingredient('burnt bun').name] = 4
    main[inv.get_ingredient('tomato sauce').name] = 5 

    mains = []
    mains.append(main)
    system.checkout(mains, None, None, inv)

    # ORDER 4
    main = {}
    main[inv.get_ingredient('muffin bun').name] = 3
    main[inv.get_ingredient('Vegetarian patty').name] = 1
    main[inv.get_ingredient('beef patty').name] = 1
    main[inv.get_ingredient('tomato sauce').name] = 1
    main[inv.get_ingredient('tomato').name] = 1
 
    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1 
    side[inv.get_ingredient('large fries').name] = 1 
    side[inv.get_ingredient('wiked wingz').name] = 1

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1
    drink[inv.get_ingredient('baijiu').name] = 1
    drink[inv.get_ingredient('whiskey').name] = 1

    mains = []
    mains.append(main)

    system.checkout(mains, side, drink, inv)

    # ORDER 5
    main = {}
    main[inv.get_ingredient('mad bun').name] = 2
    main[inv.get_ingredient('Vegetarian patty').name] = 1 
    main[inv.get_ingredient('beef patty').name] = 1
    main[inv.get_ingredient('tomato sauce').name] = 1
    main[inv.get_ingredient('tomato').name] = 1

    side = {}
    side[inv.get_ingredient('6 pack nuggets').name] = 1
    side[inv.get_ingredient('large fries').name] = 1 

    drink = {}
    drink[inv.get_ingredient('Mtn dew').name] = 1

    mains = []
    mains.append(main)
    system.checkout(mains, side, drink, inv)

    return system