def test_correct_change(self): """ if user asks for an item and pays too much they should get the correct change . """ item, change, _ = give_item_and_change('coke', 1.00) self.assertEqual(change, [.20, .05, .02])
def test_not_enough_money(self): """if user asks for an item but pays too little, they should not be given the item, and their money should be returned """ item, change, _ = give_item_and_change('coke', .50) self.assertIsNone(item) self.assertEqual(change, .50)
def test_unavailable_item(self): """if user asks for an item that's unavailable, they should not be given the item, and their money should be returned""" item, change, _ = give_item_and_change('crisps', .50) # the use of the _ is a convention to denote a throwaway # variable name that is being deliberately ignored. self.assertIsNone(item) # we use assertIsNone but we could have used assertEqual(item, None) self.assertEqual(change, .50)
def test_unavailable_item(self): """if user asks for an item that's unavailable, they should not be given the item and their money should be returned. """ # The use of the _ is a convention to denote a throwaway # variable name that is being deliberately ignored. item, change, _ = give_item_and_change('crisps', .50) self.assertIsNone(item) self.assertEqual(change, .50)
def test_unavailable_item(self): """if user asks for an item that's unavailable, they should not be given the item, and their money should be returned""" item, change, _ = give_item_and_change('crisps', .50) self.assertIsNone(item) """changed the machine so it becomes evil and returns .10 less than the amount paid""" self.assertEqual(change, 0.4)
def test_give_item_and_change_amount_works_with_correct_money(self): """tests is amount is less than the cost""" item, change, _ = give_item_and_change('coke', 2.0) self.assertIsNotNone(item) self.assertEqual(item, 'coke') self.assertEqual(change, [1,.20, .05, .02])
def test_give_item_and_change_amount_less_than_cost(self): """tests is amount is less than the cost""" item, change, _ = give_item_and_change('coke', .50) self.assertIsNone(item) self.assertEqual(change, 0.5)
def test_unavailable_item(self): """if user asks for an item that's unavailable, they should not be given the item, and their money should be returned""" item, change, _ = give_item_and_change('crisps', .50) self.assertIsNone(item) self.assertEqual(change, 0.5)
def test_lots_of_coins(self): """enter multiple coins""" item, change, _ = give_item_and_change('coke', [0.5, 0.05, 0.05, 0.1, 0.1, 0.1, 0.1]) self.assertEqual(change, [.2, .05, .02])
def test_not_enough_money(self): """if user does not have enough money for item, they should be told so""" _, _, message = give_item_and_change('coke', 0.2) self.assertEqual(message, 'not enough money')
def test_give_item_and_change(self): """normal test""" item, change, _ = give_item_and_change('coke', 1) self.assertEqual(change,[.2, .05, .02])
def test_not_enough_money(self): """if the user doesn't put enough money in, nothing will be provided the amount they have put in will be returned""" item, change, _ = give_item_and_change('coke', .70) self.assertLess(.70, 0.73)
def test_not_enough_money(self): """if user doesn't have enough money to pay, their money should be returned""" item, change, _ = give_item_and_change('coke', .60) self.assertIsNone(item) self.assertEqual(change, .60)
def test_correct_change(self): """if user asks for an item and pays too much they should get the correct change """ item, change, _ = give_item_and_change('coke', 1.00) self.assertEqual(change, [.20, .05, .02])
def test_for_enough_money(self): """if the user provides enough money for the item, then the item, change and writing should be issued""" item, change, _ = give_item_and_change('apple', .50) self.assertIsNotNone(item) self.assertEqual(change, [0.05, 0.02])
def test_give_correct_change(self): """if user enters a valid item, and enough money, they should get the correct change""" item, change, _ = give_item_and_change('coke', 1) self.assertEqual(item, 'coke') self.assertEqual(change, [.20, .05, .02])
def test_amount_not_enough(self): """if user enters an amount that is not enough, they should not be given the item and their money should be returned""" item, change, _ = give_item_and_change('coke', .50) self.assertIsNone(item) self.assertEqual(change, 0.5)
def test_change_given(self): item, change, _ = give_item_and_change('biscuits', 1.50) self.assertEqual(item, 'biscuits') self.assertEqual(change, [0.2, 0.1, 0.05])
def test_not_enough_money(self): """if user does not provide enough money to buy item, they should not be given the item, and their money should be returned""" item, change, _ = give_item_and_change('coke', .50) self.assertIsNone(item) self.assertEqual(change, .50)