Exemplo n.º 1
0
def menu() -> None:
    """Наше меню."""
    print(" " * 60, "😋 Наше меню 😋\n", end="")
    pizzas_list = [
        Pepperoni(size="L"),
        Pepperoni(size="XL"),
        Margherita(size="L"),
        Margherita(size="XL"),
        Hawaii(size="L"),
        Hawaii(size="XL"),
    ]
    for p in pizzas_list:
        print("-{pizza}".format(pizza=p))
Exemplo n.º 2
0
def test_eq():
    margherita_1 = Margherita()
    margherita_2 = Margherita()
    hawaiian_1 = Hawaiian()
    hawaiian_2 = Hawaiian()
    pepperoni_1 = Pepperoni()
    pepperoni_2 = Pepperoni()
    assert margherita_1 == margherita_2
    assert hawaiian_1 == hawaiian_2
    assert pepperoni_1 == pepperoni_2
    assert margherita_1 != hawaiian_1
    assert margherita_1 != pepperoni_1
    assert hawaiian_1 != pepperoni_1
Exemplo n.º 3
0
def menu() -> None:
    """Выводит меню"""

    pizzas = [
        Margherita(size="L"),
        Margherita(size="XL"),
        Hawaiian(size="L"),
        Hawaiian(size="XL"),
        Pepperoni(size="L"),
        Pepperoni(size="XL")
    ]
    print("🍕 Меню:")
    for pizza in pizzas:
        print('-', pizza, '(' + pizza.size + ') \n',
              ', '.join(pizza.ingredients.keys()))
Exemplo n.º 4
0
def test_name():
    margherita_1 = Margherita()
    hawaiian_1 = Hawaiian()
    pepperoni_1 = Pepperoni()
    assert margherita_1.name == 'Margherita 🧀'
    assert hawaiian_1.name == 'Hawaiian 🍍'
    assert pepperoni_1.name == 'Pepperoni 🍕'
Exemplo n.º 5
0
class Terminal:
    menu = [Pepperoni(), BBQ(), Seafood()]

    def greet(self):
        os.system("clear")
        print("{:-^40}".format("Welcome to Pizza Time"))

    def start(self, code):
        self.__code = code
        self.greet()
        print("{:^40}".format("Is it a takeout? y/n"))
        current_order = Order(self.__code, True) if input() == (
            "y" or "Y") else Order(self.__code)

        while True:
            self.greet()
            print(current_order)
            print("\nChoose your pizza:")
            for p in range(len(self.menu)):
                position = self.menu[p]
                print("{} - ${:.2f} - {}".format(p + 1, position.cost,
                                                 position.title))
            print("Enter the id of pizza, or 0 to finish")
            chosen = int(input())

            if chosen in range(len(self.menu) + 1):
                if chosen == 0:
                    break
                chosen_pizza = self.menu[chosen - 1]
                try:
                    current_order.add(chosen_pizza)
                except Exception as e:
                    print(e)
                    print("Press enter to continue to checkout...")
                    input()
                    break

                baking = threading.Thread(target=chosen_pizza.bake)
                packing = threading.Thread(target=chosen_pizza.pack,
                                           args=(current_order.takeout, ))
                baking.start()
                packing.start()
            else:
                continue

            baking.join()
            packing.join()
            print("\n1 - Choose another\n0 - Finish the order")

            if input() == "1":
                continue
            else:
                break

        self.greet()
        print(current_order)
        print("Proceed to checkout...")
        print("You can pick up your order " + Handout.location_of_pickup)
        self.__code += 1
Exemplo n.º 6
0
def test_str():
    """Тест метода str для рецепта пицц."""
    excepted = (
        "Pepperoni🍕 XL : 🥟 dough: 750г, 🧀 cheese: 187г, 🥤 water: "
        "187г, 🍅 tomato sauce: 75г, 🧂 salt: 30г, 🍖 sausage: 300г, "
        "🌶 hot pepper: 30г, 🧅 onion: 30г"
    )
    assert str(Pepperoni(size="XL")) == excepted
Exemplo n.º 7
0
def test_dict():
    excepted = {
        '🍅 tomato sauce': None,
        '🧀 mozarella': None,
        '🌭 pepperoni': None,
        '🌶 pepper': None
    }

    assert Pepperoni(size="L").dict() == excepted
Exemplo n.º 8
0
def test_deco_bake_xl():
    """Тест функции bake для пиццы размера XL, после применения декоратора."""
    my_randint = 7
    # Вызываем randint() из random, заменив возвращаемое значение на my_randint
    with patch.object(random, "randint", return_value=my_randint):
        assert (
            bake(Pepperoni(size="XL"))
            == "🍺 Приготовили Pepperoni🍕 XL за ⌚ 14мин!"
        )
Exemplo n.º 9
0
def test_eql():
    """Тест метода сравнения пицц с помощью равенства."""
    margherita_l1 = Margherita(size="L")
    margherita_l2 = Margherita(size="L")
    margherita_xl = Margherita(size="XL")
    pepperoni_xl = Pepperoni(size="XL")
    assert (
        margherita_l1 == margherita_l2
        and margherita_l1 != margherita_xl
        and margherita_xl != pepperoni_xl
    )
Exemplo n.º 10
0
def test_dict():
    """Тест метода dict(self), возвращающего словарь рецепта."""
    excepted = {
        "🥟 dough": 500,
        "🧀 cheese": 125,
        "🥤 water": 125,
        "🍅 tomato sauce": 50,
        "🧂 salt": 20,
        "🍖 sausage": 200,
        "🌶 hot pepper": 20,
        "🧅 onion": 20,
    }

    assert Pepperoni(size="L").dict() == excepted
Exemplo n.º 11
0
def menu() -> None:
    """
    Pizzeria menu
    """
    print("Меню:\n", end="")
    pizza_list = [
        Pepperoni(size="L"),
        Pepperoni(size="XL"),
        Margherita(size="L"),
        Margherita(size="XL"),
        Hawaii(size="L"),
        Hawaii(size="XL"),
    ]
    for element in pizza_list:
        print("-{pizza}".format(pizza=element))

    print(
        "Чтобы заказать пиццу, "
        "наберите в терминале: python cli.py order "
        "название_пиццы размер_пиццы, "
        "и если вы хотите доставку, "
        "допишите --delivery :\n",
        end="")
Exemplo n.º 12
0
class Terminal:
    menu = [Pepperoni(), BBQ(), Seafood()]
    __code = 0

    def greet(self):
        os.system("clear")
        print("{:-^40}".format("Welcome to Pizza Time"))

    def boot(self):
        self.greet()
        print("{:^40}".format("Is it a takeout? y/n"))
        current_order = Order(self.__code, True) if input() == (
            "y" or "Y") else Order(self.__code)

        while True:
            self.greet()
            print(current_order)
            print("\nChoose your pizza:")
            for p in range(len(self.menu)):
                position = self.menu[p]
                print("{} - ${:.2f} - {}".format(p + 1, position.cost,
                                                 position.title))
            print("Enter the id of pizza, or 0 to finish")
            chosen = int(input())

            if chosen in range(len(self.menu) + 1):
                if chosen == 0:
                    break
                chosen_pizza = self.menu[chosen - 1]
                current_order.add(chosen_pizza)
                chosen_pizza.bake()
                chosen_pizza.pack(current_order.takeout)
            else:
                continue

            print("\n1 - Choose another\n0 - Finish the order")

            if input() == "1":
                continue
            else:
                break

        self.greet()
        print(current_order)
        print("Proceed to checkout...")
        self.__code += 1
Exemplo n.º 13
0
def order(pizza: str, size: str = 'L', delivery_order: bool = False):
    """Готовит и доставляет пиццу"""
    Menu = {'Margherita': Margherita(size),
            'Pepperoni': Pepperoni(size),
            'Hawaiian': Hawaiian(size)}
    if pizza not in Menu.keys():
        print(
            "Такой пиццы нет в меню. "
            "Выберите одну из других пицц: ")
        for element in MENU.values():
            print('--', element.name, element.symbol, ':')
            element.dict()
        return
    pizza_to_make = Menu[pizza]
    if delivery_order is False:
        bake(pizza_to_make)
    else:
        bake(pizza_to_make)
        delivery(pizza_to_make)
Exemplo n.º 14
0
def test_str():
    excepted = ("Pepperoni🍕 XL")
    assert str(Pepperoni(size="XL")) == excepted
Exemplo n.º 15
0
def test_bake_XL_decorated():
    my_randint = 21
    with patch.object(random, "randint", return_value=my_randint):
        assert (bake(Pepperoni(
            size="XL")) == "👨‍🍳 Приготовили Pepperoni🍕 XL за 21 мин.!")
Exemplo n.º 16
0
def test_orig_pickup():
    """Тест функции pickup, без применения декоратора."""
    original_pickup = pickup.__wrapped__
    assert original_pickup(Pepperoni(size="XL")) == "🏡 Забрали"
Exemplo n.º 17
0
class Terminal:
    menu = {"Pepperoni": Pepperoni(), "BBQ": BBQ(), "Seafood": Seafood()}
    screen = 0
    log_history = ""

    def __init__(self):
        self.window = Tk()
        self.window.title("Pizza Time Terminal")
        self.window.geometry("480x240")
        self.window.configure()

        header = Label(self.window,
                       text="Welcome to Pizza Time!",
                       font=("Helvetica", 27, "bold"),
                       pady="20")

        self.status_text = StringVar()
        self.status_text.set("Is it a takeout?")
        status = Label(self.window,
                       textvariable=self.status_text,
                       font=("Helvetica", 20))

        self.pizzas = Frame(self.window)

        self.log_text = StringVar()
        self.log = Label(self.window,
                         textvariable=self.log_text,
                         font=("Helvetica", 16, "italic"),
                         fg="grey",
                         anchor="s")

        navbar = Frame(width="5")
        self.main = Button(navbar,
                           text="Yes",
                           command=lambda: self.set_current_order(True),
                           width="100",
                           font=("Helvetica", 20),
                           pady="10")
        self.secondary = Button(navbar,
                                text="No",
                                command=lambda: self.set_current_order(False),
                                width="100",
                                font=("Helvetica", 20),
                                pady="10")

        header.pack(side=TOP)
        status.pack(side=TOP)

        self.pizzas.pack(side=TOP)

        self.main.pack()
        self.secondary.pack()
        navbar.pack(side=BOTTOM)
        self.log.pack(side=BOTTOM)

    def update_status(self, message):
        self.status_text.set(message)

    def update_pizzas(self):
        available = []

        for pizza in asyncio.run(check_availability()):
            available.append(self.menu[pizza])

        for widget in self.pizzas.winfo_children():
            widget.destroy()

        Label(self.pizzas,
              text="CHOOSE YOUR PIZZA",
              pady="3",
              font=("Helvetica", 16, "bold")).pack(pady="10")
        for pizza in available:
            pizza_button = Button(self.pizzas,
                                  command=lambda p=pizza: self.select_pizza(p),
                                  text="{} - ${}".format(
                                      pizza.title, pizza.cost),
                                  width="20",
                                  pady=10,
                                  font=("Helvetica", 20, "bold"))
            pizza_button.pack(pady="5")

    def update_navbar(self):
        if self.screen == 1:
            self.window.geometry("480x640")
            self.update_pizzas()
            self.main.config(text="Proceed to checkout", command=self.checkout)
            self.secondary.config(text="Cancel the order", command=self.reset)
        if self.screen == 2:
            self.window.geometry("480x240")
            self.main.config(text="Create another order", command=self.reset)
            self.secondary.config(text="Exit the terminal",
                                  command=self.window.destroy)

    def set_current_order(self, takeout):
        self.current_order = Order(self.__code, takeout)
        self.screen = 1
        self.log.configure(height="5", pady="20")
        self.update_navbar()
        self.update_status(self.current_order)

    def select_pizza(self, pizza):
        try:
            self.current_order.add(pizza)

            if len(self.current_order.order_list) > 4:
                self.update_status(self.current_order.__str__() +
                                   "\n DISCOUNT 20%")
            else:
                self.update_status(self.current_order)

            packing = threading.Thread(target=pizza.pack,
                                       args=(self.current_order.takeout, ))
            baking = threading.Thread(target=pizza.bake)

            baking.start()
            packing.start()

            baking.join()
            self.update_log("{} pizza is baked!".format(pizza.title))
            packing.join()
            self.update_log("{} pizza is packed!".format(pizza.title))
        except Exception as e:
            self.update_log(e.__str__())

    def update_log(self, message):
        self.log_history += "\n" + message
        self.log_text.set(self.log_history)

    def start(self, code):
        self.__code = code
        self.window.mainloop()

    def checkout(self):
        self.screen = 2
        self.update_status(
            "Order #{} is ready.\nYou can pick up your order {}".format(
                self.__code, Handout.location_of_pickup))
        self.pizzas.destroy()
        self.log.destroy()
        self.update_navbar()
        self.__code += 1

    def reset(self):
        self.window.destroy()
        self.__init__()
        self.screen = 0
        self.log_history = ""
Exemplo n.º 18
0
def menu():
    Margarita().__str__()
    Pepperoni().__str__()
    Hawaiian().__str__()
Exemplo n.º 19
0
import click
from pizza import Margherita, Pepperoni, Hawaiian
from random import randint

MENU = {'Margherita': Margherita(),
        'Pepperoni': Pepperoni(),
        'Hawaiian': Hawaiian()}


def log(template: str):
    def decorator(func):
        def wrapper(*args, **kwargs):
            result = func(*args, **kwargs)
            print(template.format(randint(50, 1200)))
            return result

        return wrapper

    return decorator


@click.group()
def cli():
    pass


@cli.command()
@click.option('--delivery_order', default=False, is_flag=True)
@click.argument('pizza', nargs=1)
@click.argument('size', nargs=1)
def order(pizza: str, size: str = 'L', delivery_order: bool = False):
Exemplo n.º 20
0
def test_pickup_no_decorator():
    original_pickup = pickup.__wrapped__
    assert original_pickup(Pepperoni(size="XL")) == "🚶 🏠 Самовывоз"