Exemplo n.º 1
0
def test_delete_order(inventory_fixture, ingredient_cost_fixture):
    system1 = System(inventory_fixture, ingredient_cost_fixture)
    assert (isinstance(system1, System))
    order1 = system1.Create_Order()
    assert (isinstance(order1, Order))

    orig_white_bun = system1.Inventory["white"]
    orig_beef = system1.Inventory["beef"]
    orig_cheese = system1.Inventory["cheese"]
    orig_tortilla = system1.Inventory["tortilla"]
    orig_tuna = system1.Inventory["tuna"]
    orig_lettuce = system1.Inventory["lettuce"]
    orig_onion = system1.Inventory["onion"]
    orig_tomato = system1.Inventory["tomato"]
    orig_avocado = system1.Inventory["avocado"]

    burg1 = order1.Create_Item("Burger")
    burg1.Bun_Type = "white"
    burg1.Add_Bun()
    burg1.Add_Bun()
    burg1.Patty_Type = "beef"
    burg1.Add_Patty()
    burg1.Add_Other("cheese")
    order1.Add_To_Order(burg1)
    assert (burg1 in order1.Items)
    assert (order1.Calculate_Cost() == 9)

    wrap1 = order1.Create_Item("Wrap")
    wrap1.Wrap_Type = "tortilla"
    wrap1.Filling_Type = "tuna"
    wrap1.Add_Other("cheese")
    wrap1.Add_Other("lettuce")
    wrap1.Add_Other("onion")
    wrap1.Add_Other("tomato")
    wrap1.Add_Other("avocado")
    order1.Add_To_Order(wrap1)
    assert (wrap1 in order1.Items)
    assert (order1.Calculate_Cost() == 38.5)
    assert (len(order1.Items) == 2)

    assert (system1.Inventory["white"] == (orig_white_bun - 2))
    assert (system1.Inventory["beef"] == (orig_beef - 1))
    assert (system1.Inventory["cheese"] == (orig_cheese - 2))
    assert (system1.Inventory["tortilla"] == (orig_tortilla - 1))
    assert (system1.Inventory["tuna"] == (orig_tuna - 1))
    assert (system1.Inventory["lettuce"] == (orig_lettuce - 1))
    assert (system1.Inventory["onion"] == (orig_onion - 1))
    assert (system1.Inventory["tomato"] == (orig_tomato - 1))
    assert (system1.Inventory["avocado"] == (orig_avocado - 1))

    assert (order1.ID == None)
    assert (order1.Status == None)
    try:
        system1.Check_Status(0)
    except SystemError as err:
        assert (err.message == "Order not found.")
    else:
        assert (False)

    system1.Delete_Order(order1)
    assert (system1.Inventory["white"] == (orig_white_bun))
    assert (system1.Inventory["beef"] == (orig_beef))
    assert (system1.Inventory["cheese"] == (orig_cheese))
    assert (system1.Inventory["tortilla"] == (orig_tortilla))
    assert (system1.Inventory["tuna"] == (orig_tuna))
    assert (system1.Inventory["lettuce"] == (orig_lettuce))
    assert (system1.Inventory["onion"] == (orig_onion))
    assert (system1.Inventory["tomato"] == (orig_tomato))
    assert (system1.Inventory["avocado"] == (orig_avocado))