Exemplo n.º 1
0
def test_remIngredient_incorrectinput():
    sys = System()
    sys.addQuantityIngredient('sesame bun', 'm', 20, 1.00)
    with pytest.raises(DevError) as err:
        sys.remIngredient(1)
    assert 'cannot delete. no such ingredient in the inventory' in str(
        err.value)
Exemplo n.º 2
0
def test_remIngredient_correctinput():
    sys = System()
    sys.addQuantityIngredient('sesame bun', 'm', 20, 1.00)
    sys.addWeightIngredient('fries', 'm', 2000, 60, 100, 140, 2, 2.8, 3.4)
    sys.remIngredient(4)
    assert len(sys.ingredients) == 1
    assert sys.ingredients[0].name == 'sesame bun'
Exemplo n.º 3
0
def test_remIngredient_incorrect_input_no_ings_in_order():
    sys = System()
    wrap = Main('wrap')
    sys.addQuantityIngredient('beef patty', 'm', 50, 1.50)
    ing1 = sys.ingredients[0]

    with pytest.raises(UserError) as error:
        wrap.remIngredient(ing1, 1, None)
    assert "You don't have any ingredients in your main to remove." in str(error.value)
Exemplo n.º 4
0
def test_addQuantityIngredient_correct_input():
    sys = System()
    sys.addQuantityIngredient('bun', 'm', 20, 5)
    new = sys.ingredients[0]
    assert new.id == 1
    assert new.name == 'bun'
    assert new.kind == 'm'
    assert new.stock == 20
    assert new.price == 5
Exemplo n.º 5
0
def test_remIngredient_incorrect_input():
    sys = System()
    sys.addQuantityIngredient('beef patty', 'm', 50, 1.50)
    sys.addQuantityIngredient('cheese', 'm', 50, 1.00)
    sys.addQuantityIngredient('egg', 'm', 50, 1.50)
    ing1 = sys.ingredients[0]
    ing2 = sys.ingredients[1]
    ing3 = sys.ingredients[2]

    wrap = Main('wrap')
    wrap.addIngredient(ing1, 2, None)
    wrap.addIngredient(ing2, 2, None)
    with pytest.raises(UserError) as error:
        wrap.remIngredient(ing3, 1, None)
    assert "You don't have any egg in your order to remove." in str(error.value)
Exemplo n.º 6
0
def test_remIngredient_correct_input():
    sys = System()
    sys.addQuantityIngredient('beef patty', 'm', 50, 1.50)
    sys.addQuantityIngredient('cheese', 'm', 50, 1.00)
    sys.addQuantityIngredient('egg', 'm', 50, 1.50)
    ing1 = sys.ingredients[0]
    ing2 = sys.ingredients[1]
    ing3 = sys.ingredients[2]

    wrap = Main('wrap')
    wrap.addIngredient(ing1, 2, None)
    wrap.addIngredient(ing2, 2, None)
    wrap.addIngredient(ing3, 1, None)

    wrap.remIngredient(ing3, 1, None)
    assert len(wrap.ingredients) == 2
    assert sys.ingredients[2].stock == 50
Exemplo n.º 7
0
def test_addQuantityIngredient_price_is_negative():
    sys = System()
    with pytest.raises(UserError) as e:
        sys.addQuantityIngredient('sesame bun', 'm', 20, -5)
    assert 'Price of ingredient must be positive' in str(e.value)
Exemplo n.º 8
0
def test_addQuantityIngredient_price_is_string():
    sys = System()
    with pytest.raises(UserError) as e:
        sys.addQuantityIngredient('sesame bun', 'm', 20, 'asdf')
    assert 'Price of ingredient must be a number' in str(e.value)
Exemplo n.º 9
0
def test_addQuantityIngredient_stock_is_negative():
    sys = System()
    with pytest.raises(UserError) as error:
        sys.addQuantityIngredient('sugar', 's', -20, 3)
    assert 'Stock of ingredient must be positive' in str(error.value)
Exemplo n.º 10
0
def test_addQuantityIngredient_stock_is_string():
    sys = System()
    with pytest.raises(UserError) as error:
        sys.addQuantityIngredient('sugar', 'm', 'unsw', 5)
    assert 'Stock of ingredient must be in number' in str(error.value)
Exemplo n.º 11
0
def test_addQuantityIngredient_wrong_name():
    sys = System()
    with pytest.raises(UserError) as error:
        sys.addQuantityIngredient(465, 'm', 20, 5)
    assert 'Name of ingredient must be in alphabets' in str(error.value)