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
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'
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'
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'
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)
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
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'
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"
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)