Пример #1
0
def test_get_price():
    with open(os.path.dirname(__file__) + '/../data.json') as f:
        data = json.load(f)
    pizza = Pizza(['vegetarian', 'medium', ['beef', 'olives']])
    price = data['pizza']['vegetarian']['medium']
    price += data['topping']['beef']
    price += data['topping']['olives']
    assert pizza.get_price() == price

    pizza = Pizza(['vegetarian', 'small', ['chicken', 'beef']])
    price = data['pizza']['vegetarian']['small']
    price += data['topping']['chicken']
    price += data['topping']['beef']
    assert pizza.get_price() == price
Пример #2
0
def test_get_dict():
    pizza = Pizza(['vegetarian', 'medium', ['chicken', 'beef']])
    pizza_dict = pizza.get_dict()
    assert "type" in pizza_dict
    assert "size" in pizza_dict
    assert "toppings" in pizza_dict
    assert "price" in pizza_dict and isinstance(pizza_dict["price"], int)
Пример #3
0
 def __init__(self, pizza_config):
     self.pizza = Pizza(pizza_config['pizza_lines'])
     self.min_each_ingredient_per_slice = pizza_config['l']
     self.max_ingredients_per_slice = pizza_config['h']
     self.cursor_position = (0,0)
     self.slice_mode = False
     self.valid_slices = []
     self.score = 0
Пример #4
0
def manual_price_update():
    pizza = Pizza(['vegetarian', 'medium', ['chicken', 'beef']])
    rand1 = random.randint(1, 100)
    price1 = pizza.manual_price_update(rand1)
    assert price1 == rand1

    rand2 = random.randint(1, 100)
    price2 = pizza.manual_price_update(rand2)
    assert price2 == rand2
Пример #5
0
def test_check_inputs():
    pizza = Pizza(['pepperoni', 'medium', ['olives', 'beef']])
    assert pizza.check_inputs(['pepperoni', 'medium', ['olives',
                                                       'beef']]) == True
    assert pizza.check_inputs(['vegetarian', 'small', ['chicken']]) == True
    assert pizza.check_inputs(['pepperoni', 'medium', []]) == True
    assert pizza.check_inputs(['invalid', 'medium', ['olives',
                                                     'beef']]) == False
    assert pizza.check_inputs(['pepperoni', 'invalid', ['olives',
                                                        'beef']]) == False
    assert pizza.check_inputs(['pepperoni', 'medium', ['invalid',
                                                       'beef']]) == False
    assert pizza.check_inputs(['pepperoni', 'medium', 'invalid']) == False
Пример #6
0
def test_update():
    pizza = Pizza(['pepperoni', 'small', ['chicken', 'olives']])
    assert pizza.get_size() == 'small'
    pizza.update([-1, 'medium', -1])
    assert pizza.get_size() == 'medium'

    pizza = Pizza(['vegetarian', 'medium', ['beef', 'olives']])
    assert pizza.get_type() == 'vegetarian'
    pizza.update(['pepperoni', -1, -1])
    assert pizza.get_type() == 'pepperoni'

    pizza = Pizza(['vegetarian', 'small', ['chicken', 'beef']])
    assert pizza.get_toppings() == ['chicken', 'beef']
    pizza.update([-1, -1, ['olives']])
    assert pizza.get_toppings() == ['olives']

    pizza = Pizza(['pepperoni', 'small', ['chicken', 'olives']])
    assert not pizza.update([-1, 'invalid', -1])

    pizza = Pizza(['vegetarian', 'medium', ['beef', 'olives']])
    assert not pizza.update(['invalid', -1, -1])

    pizza = Pizza(['vegetarian', 'small', ['chicken', 'beef']])
    assert not pizza.update([-1, -1, 'invalid'])
Пример #7
0
def test_get_size():
    pizza = Pizza(['pepperoni', 'small', ['chicken', 'olives']])
    assert pizza.get_type() == 'pepperoni'

    pizza = Pizza(['vegetarian', 'medium', ['beef', 'olives']])
    assert pizza.get_type() == 'vegetarian'
Пример #8
0
def test_get_toppings():
    pizza = Pizza(['pepperoni', 'small', ['chicken', 'olives']])
    assert pizza.get_toppings() == ['chicken', 'olives']

    pizza = Pizza(['vegetarian', 'medium', ['beef', 'olives']])
    assert pizza.get_toppings() == ['beef', 'olives']
Пример #9
0
 def add_pizza(self, pizza_info):
     """Creates a pizza object using pizza_info and appends this pizza to the self.pizzas list.
     May throw exception if pizza_info is invalid"""
     pizza = Pizza(pizza_info)
     self.pizzas.append(pizza)