예제 #1
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
예제 #2
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
예제 #3
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
    }