def test_makeOrder_functionality_multiple_orders_with_wait():
    """ Test to see if makeOrder works for multiple orders.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {"hot_tea": {"milk": 1}}
    total_items_qty = {"milk": 2}
    orders = ["hot_tea", "hot_tea", "hot_tea", "hot_tea", "hot_tea", "hot_tea"]

    CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
    CM.makeOrder(orders)

    assert CM.raw_material_qty["milk"] == 0
def test_makeOrder_functionality_str_input():
    """ Test to see if makeOrder works for single string input.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {"hot_tea": {"milk": 1}}
    total_items_qty = {"milk": 2}
    orders = "hot_tea"

    CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
    CM.makeOrder(orders)

    assert CM.raw_material_qty["milk"] == 1
def test_makeOrder_zero_len():
    """ Test to see if makeOrder works with zero length order.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {"hot_tea": {"milk": 1}}
    total_items_qty = {"milk": 2}
    orders = []

    CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
    CM.makeOrder(orders)

    assert CM.raw_material_qty["milk"] == 2
def test_makeOrder_order_unknown_drink():
    """ Test to see if makeOrder works with wrong drink type in order.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {"hot_tea": {"milk": 1}}
    total_items_qty = {"milk": 2}
    orders = ["coffee"]

    CM = CoffeeMachine(num_outlets, beverages, total_items_qty)

    with pytest.raises(ValueError, match="for ordered drink is not known."):
        CM.makeOrder(orders)
def test_makeOrder_order_type():
    """ Test to see if makeOrder works with wrong order type.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {"hot_tea": {"milk": 1}}
    total_items_qty = {"milk": 2}
    orders = {}

    CM = CoffeeMachine(num_outlets, beverages, total_items_qty)

    with pytest.raises(ValueError, match="Orders were expected in a list."):
        CM.makeOrder(orders)
Example #6
0
filename = "test_data/temp_orders.txt"
f = open(filename, "r")
orders = f.readlines()

# Remove line breaks from orders
for i in range(len(orders)):
    orders[i] = orders[i][:-1]

# Instantiate the Coffee Machine
CM = CoffeeMachine(num_outlets, beverages, total_items_qty)

# Check the menu of the coffee machine
menu = CM.menu

print()
print("-------------------------------------------------")  
print("The drinks available in the machine are : ")
print(menu)

print()
print("-------------------------------------------------")  

# See which drinks can be made concurrently from the menu

# for element in menu:
#   CM.makeDrink(element)

CM.makeOrder(orders)

print("-------------------------------------------------")
print()