def test_twenty_cent_extra(self): cm = CoffeeMachine() self.assertDictEqual( cm.return_coins(3.14, 3.34), { 'num_one_cent_coins': 0, 'num_two_cent_coins': 0, 'num_five_cent_coins': 0, 'num_ten_cent_coins': 0, 'num_twenty_cent_coins': 1, 'num_fifty_cent_coins': 0, 'num_one_euro_coins': 0, 'num_two_euro_coins': 0 })
def test_return_one_of_each_coin(self): cm = CoffeeMachine() self.assertDictEqual( cm.return_coins(3.14, 7.02), { 'num_one_cent_coins': 1, 'num_two_cent_coins': 1, 'num_five_cent_coins': 1, 'num_ten_cent_coins': 1, 'num_twenty_cent_coins': 1, 'num_fifty_cent_coins': 1, 'num_one_euro_coins': 1, 'num_two_euro_coins': 1 })
def test_example(self): cm = CoffeeMachine() self.assertDictEqual( cm.return_coins(3.14, 500), { 'num_one_cent_coins': 1, 'num_two_cent_coins': 0, 'num_five_cent_coins': 1, 'num_ten_cent_coins': 1, 'num_twenty_cent_coins': 1, 'num_fifty_cent_coins': 1, 'num_one_euro_coins': 0, 'num_two_euro_coins': 248 })
def test_zero_money_inserted_and_coffee_set_to_zero(self): cm = CoffeeMachine() self.assertDictEqual( cm.return_coins(0, 0), { 'num_one_cent_coins': 0, 'num_two_cent_coins': 0, 'num_five_cent_coins': 0, 'num_ten_cent_coins': 0, 'num_twenty_cent_coins': 0, 'num_fifty_cent_coins': 0, 'num_one_euro_coins': 0, 'num_two_euro_coins': 0 })
def test_set_to_negative(self): cm = CoffeeMachine() self.assertRaises(Exception, cm.return_coins, -0.1, 500) # Coffee price set to negative
def test_negative_money_inserted(self): cm = CoffeeMachine() self.assertRaises(Exception, cm.return_coins, 3.14, -0.1) # Negative money inserted
def test_not_enough_money_inserted(self): cm = CoffeeMachine() self.assertRaises(Exception, cm.return_coins, 3.14, 3.13) # not enough money inserted
def test_i_want_an_extra_hot_tea(self): message = CoffeeMachine().order(Drink.Chocolate, 0, 0.6) self.assertEqual(message, "C::")
def test_tea_with_1_sugar(self): message = CoffeeMachine().order(Drink.Tea,1,42) self.assertEqual(message, "T:1:0")
def test_enough_money_provided_to_buy_chocolate(self): message = CoffeeMachine().order(Drink.Chocolate, 1, 0.5) self.assertEqual(message, "H:1:0")
def test_i_want_an_orangejuice(self): message = CoffeeMachine().order(Drink.OrangeJuice, 0, 0.6) self.assertEqual(message, "O::")
def test_enough_money_provided_to_buy_chocolate_with_no_sugar(self): message = CoffeeMachine().order(Drink.Chocolate, 0, 0.5) self.assertEqual(message, "H::")
def test_not_enough_money_provided(self): message = CoffeeMachine().order(Drink.Chocolate, 0, 0) self.assertEqual(message, "M:Missing 0.50")
def test_chocolate_with_one_sugar(self): message = CoffeeMachine().order(Drink.Chocolate,1,1) self.assertEqual(message, "H:1:0")
def test_coffee_with_1_sugar(self): message = CoffeeMachine().order(Drink.Covfefe,1,1) self.assertEqual(message, "C:1:0")
from coffeemachine import CoffeeMachine if __name__ == '__main__': CoffeeMachine(400, 540, 120, 9, 550).control()