Ejemplo n.º 1
0
    def test_coffee_refill(self):
        test_data = read_json_file(self.test_file)
        coffee_machine = CoffeeMachine(2)
        coffee_machine.add_items(test_data['machine']['total_items_quantity'])
        coffee_machine.refill("hot_water", 100)
        coffee_machine.ingredient_store_read()

        self.assertEqual(coffee_machine.items['hot_water'], 600)
        coffee_machine.delete_storage()
Ejemplo n.º 2
0
def test_refill_functionality():
    """ Test if the refill function works properly
    """

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

    CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
    CM.refill("milk", 1)

    assert CM.raw_material_qty["milk"] == 2
Ejemplo n.º 3
0
def test_refill_positive_value():
    """ Test to check if refill method works if final value after 
    adding ingredient becomes negative.
    """

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

    with pytest.raises(ValueError, match="Cannot add because final quantity"):
        CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
        CM.refill("milk", -2)
Ejemplo n.º 4
0
def test_refill_unknown_ingredient():
    """ Test to check if refill method works if ingredient is not in 
    coffee machine.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {}
    total_items_qty = {}

    with pytest.raises(ValueError, match="Ingredient not in coffee machine."):
        CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
        CM.refill("milk", 1)
Ejemplo n.º 5
0
def test_refill_qty_type():
    """ Test to check if refill method works if ingredient quantity given 
    is not an int.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {}
    total_items_qty = {}

    with pytest.raises(ValueError, match="Quantity is not an integer."):
        CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
        CM.refill("milk", "hello")
Ejemplo n.º 6
0
def test_refill_ingredient_type():
    """ Test to check if refill method works if ingredient given is not a 
    string.
    """

    # assign data to pass to coffee machine
    num_outlets = 1
    beverages = {}
    total_items_qty = {}

    with pytest.raises(ValueError, match="Ingredient is not a string."):
        CM = CoffeeMachine(num_outlets, beverages, total_items_qty)
        CM.refill(1, 1)
Ejemplo n.º 7
0
def coffee_refill(outlets):
	# main method to refill ingredients

	coffee_machine = CoffeeMachine(outlets)
	# read items from storage
	coffee_machine.ingredient_store_read()

	# check if item quantity less than 30. If so ask for refill
	print("Checking Ingredients ...")	
	for item in coffee_machine.items:
		quantity = coffee_machine.items[item]
		if quantity <= 30:
			# refill ingredients
			print(item + " | Enter Quantity to refill - ")
			refill_quantity = int(input())
			coffee_machine.refill(item, refill_quantity)
	print("Machine item quantity - ")
	print(coffee_machine.items)