Пример #1
0
def test_recover_an_order():
    order = Order(sample_order, menu)
    assert order.toJSON() == {
        "order_number":
        1,
        "pizzas": [{
            "size": "L",
            "type": "pepperoni",
            "toppings": {
                "olives": 4,
                "tomatoes": 1,
                "mushrooms": 1
            },
            "number": 1,
            "item_id": 1
        }],
        "drinks": [{
            "item_id": 1,
            "drink_name": "Pepsi",
            "number": 2
        }],
        "address":
        "100 Street",
        "price":
        26.5
    }
Пример #2
0
def test_add_pizza():
    order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    pizza = {
        "size": "M",
        "type": "pepperoni",
        "toppings": {
            "olives": 2
        },
        "number": 1
    }
    order.add_pizza(pizza, menu)
    assert order.toJSON() == {
        "order_number":
        2,
        "pizzas": [{
            "item_id": 1,
            "size": "M",
            "type": "pepperoni",
            "toppings": {
                "olives": 2
            },
            "number": 1
        }],
        "drinks": [],
        "address":
        "",
        "price":
        6
    }
Пример #3
0
def test_change_drink():
    order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    drink = {"drink_name": "Coke", "number": 2}
    order.add_drink(drink, menu)
    order.change_drink({"item_id": 1, "number": 10}, menu, types)

    expected = {
        "order_number": 2,
        "pizzas": [],
        "drinks": [{
            "item_id": 1,
            "drink_name": "Coke",
            "number": 10
        }],
        "address": "",
        "price": 20
    }

    order.change_drink({"item_id": 1, "number": 0}, menu, types)

    expected = {
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": 0
    }

    assert order.toJSON() == expected
Пример #4
0
def test_toJSON():
    new_order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    assert new_order.toJSON() == {
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": 0
    }
Пример #5
0
def test_to_json():
    new_order = Order(sample_order, menu)
    uber = Uber(new_order)
    result = uber.toJSON()
    assert result == {
        'order_details': {
            "order_number":
            1,
            "pizzas": [{
                "size": "L",
                "type": "pepperoni",
                "toppings": {
                    "olives": 4,
                    "tomatoes": 1,
                    "mushrooms": 1
                },
                "number": 1,
                "item_id": 1
            }],
            "drinks": [{
                "item_id": 1,
                "drink_name": "Pepsi",
                "number": 2
            }],
            "address":
            "100 Street",
            "price":
            26.5
        }
    }
Пример #6
0
def main():
    for stock in conf_reader.MYDEF:

        current_price = truedata.get_current_data(stock.req_code)
        order = Order("buy", current_price, current_price - 10)
        stock.orders.append(order)

    pass
Пример #7
0
 def make_a_new_order(this):
     order_number = this.unique_key_maker(this.orders)
     order = {}
     order["order_number"] = order_number
     order["pizzas"] = []
     order["drinks"] = []
     order["address"] = ""
     order["price"] = ""
     this.orders.append(Order(order))
     return order_number
Пример #8
0
def test_add_drink():
    order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    drink = {"drink_name": "Coke", "number": 3}
    order.add_drink(drink, menu)
    assert order.toJSON() == {
        "order_number": 2,
        "pizzas": [],
        "drinks": [{
            "item_id": 1,
            "drink_name": "Coke",
            "number": 3
        }],
        "address": "",
        "price": 6
    }
Пример #9
0
def test_check_pizza_already_exist():
    order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    pizza = {
        "size": "M",
        "type": "pepperoni",
        "toppings": {
            "olives": 2
        },
        "number": 1
    }
    order.add_pizza(pizza, menu)
    result = order.check_pizza_already_exist(pizza)
    assert result != None
    pizza = {
        "size": "M",
        "type": "pepperoni",
        "toppings": {
            "olives": 1
        },
        "number": 1
    }
    result = order.check_pizza_already_exist(pizza)
    assert result == None
Пример #10
0
def run(deliveryman_list, store_list):
    deliveryman_ = Finder.deliveryman(deliveryman_list, 4)

    store = Finder.store(store_list, 1)
    deliveryman_.add_exclusive_store(store)
    store.create_order(Order(1, 50))
    store.create_order(Order(2, 50))
    store.create_order(Order(3, 50))

    store = Finder.store(store_list, 2)
    store.create_order(Order(1, 50))
    store.create_order(Order(2, 50))
    store.create_order(Order(3, 50))
    store.create_order(Order(4, 50))

    store = Finder.store(store_list, 3)
    store.create_order(Order(1, 50))
    store.create_order(Order(2, 50))
    store.create_order(Order(3, 100))

    for store in store_list:
        store.change_deliveryman(deliveryman_list)
Пример #11
0
def test_make_a_new_order():
    new_order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    assert new_order.order_number == 2
    assert new_order.pizzas == []
    assert new_order.drinks == []
    assert new_order.address == ""
    assert new_order.price == 0
Пример #12
0
def test_check_drink_already_exist():
    order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    drink = {"drink_name": "Coke", "number": 2}
    order.add_drink(drink, menu)
    result = order.check_drink_already_exist(drink)
    assert result != None
    drink = {"drink_name": "Coke", "number": 1}
    result = order.check_drink_already_exist(drink)
    assert result != None
    drink = {"drink_name": "Diet Coke", "number": 1}
    result = order.check_drink_already_exist(drink)
    assert result == None
Пример #13
0
def getOrders(arranged_orders):	
	"""Returns a list of Order objects from a list of lines coming from a .pz file"""
	orders = []
	# Separate each propertie from the order
	for order in arranged_orders:
		# Get Name and Date
		customer_name, order_date = order[0].split(';')

		# whenever any of these values is None, the order is cancelled when inserting to the database (due to NOT NULL constraints)
		customer_name = customer_name or None # if customer_name is empty string, assigns None value (see Short Circuit Evaluations)
		
		order_date = order_date or None
		if order_date: # if order_date is set, check format
			try:
				# Check if date is formatted in dd/mm/yyyy
				datetime.strptime(order_date, '%d/%m/%Y')
			except:
				# Not a valid date format
				order_date = None

		pizzas = []
		# Get Pizza size and toppings for each pizza in the order if a topping name is not written correctly it wont be added to the pizza.
		for line in order[1:]:
			size_toppings = line.split(';')
			size = size_toppings[0]
			toppings = size_toppings[1:]
			pizza = Pizza(size, toppings)
			pizzas.append(pizza)
			total = pizza.get_total_price()
			print('Client:', customer_name)
			print('Date:', order_date)
			print('Size:', size)
			print('Toppings (read in file):', toppings)
			print('Total:', total)
			print('')
		orders.append(Order(customer_name, order_date, pizzas))
	return orders
Пример #14
0
            main_menu()

    elif selection == 3:
        for person in person_list:
            name = person.name
            print("\n" + name + ":")
            select = input(
                f"\n \t Does {name} want to order a drink? Y or N:   ")
            if select == "Y" or select == "7":
                print("\t Please choose from the following list of drinks:  ")
                for drink in list(enumerate(drink_list, start=1)):
                    print(drink)
                    # drink_name= drink.kind
                    # print(drink_name)
                choice = input("Enter your choice here:   ")
                order = Order(name, choice)
                order_list.append(order)
            else:
                continue
        input("Press ENTER to return to the main menu")
        main_menu()

    elif selection == 4:
        for order in order_list:
            print(order)

    elif selection == 5:
        for person in person_list:
            name = person.name
            print("\n" + name + ":")
            print("\n \t Please choose from the following list of drinks:  ")
Пример #15
0
def test_new_foodora():
    new_order = Order(sample_order)
    foodora = Foodora(new_order)
    assert foodora.order_details == new_order
Пример #16
0
 def load_orders(this):
     orders = this.file_dealer.load_orders()
     for order in orders:
         this.orders.append(Order(order, this.menu))
Пример #17
0
def test_new_uber():
    new_order = Order(sample_order)
    uber = Uber(new_order)
    assert uber.order_details == new_order
Пример #18
0
def test_AddOrder():
    test_add_order = Order("Martin", "apple juice")
    expected_order_name = "Martin"
    expected_order_choice = "apple juice"
    assert test_add_order.name == expected_order_name
    assert test_add_order.choice == expected_order_choice
Пример #19
0
def test_change_pizza():
    order = Order({
        "order_number": 2,
        "pizzas": [],
        "drinks": [],
        "address": "",
        "price": ""
    })
    pizza = {
        "size": "M",
        "type": "pepperoni",
        "toppings": {
            "olives": 2,
            "mushrooms": 1
        },
        "number": 1
    }
    order.add_pizza(pizza, menu)
    order.change_pizza({
        "item_id": 1,
        "size": "L",
        "toppings": {
            "olives": 0
        }
    }, menu, types)

    expected = {
        "order_number":
        2,
        "pizzas": [{
            "item_id": 1,
            "size": "L",
            "type": "pepperoni",
            "toppings": {
                "olives": 2,
                "mushrooms": 1
            },
            "number": 1
        }],
        "drinks": [],
        "address":
        "",
        "price":
        12.0
    }

    assert order.toJSON() == expected

    order.change_pizza({
        "item_id": 1,
        "size": "L",
        "toppings": {
            "olives": 3
        }
    }, menu, types)

    expected = {
        "order_number":
        2,
        "pizzas": [{
            "item_id": 1,
            "size": "L",
            "type": "pepperoni",
            "toppings": {
                "olives": 3,
                "mushrooms": 1
            },
            "number": 1
        }],
        "drinks": [],
        "address":
        "",
        "price":
        16.5
    }

    assert order.toJSON() == expected
Пример #20
0
def test_set_address():
    order = Order(sample_order, menu)
    order.set_address("300 Street")
    assert order.address == "300 Street"
Пример #21
0
def test_new_delivery():
    new_order = Order(sample_order)
    delivery = Delivery(new_order)
    assert delivery.order_details == new_order
    assert delivery.order_number == 1