class TestPub(unittest.TestCase): def setUp(self): self.pub = Pub("The Prancing Pony", 100.00) def test_pub_has_name(self): self.assertEqual("The Prancing Pony", self.pub.name) def test_pub_has_till(self): self.assertEqual(100.00, self.pub.till) def test_add_cash_to_till(self): self.pub.add_cash_to_till(3.00) self.assertEqual(103.00, self.pub.till) def test_check_over_age_true(self): customer = Customer("Colin", 20.00, 25) customer_is_old_enough = self.pub.check_age(customer.age) self.assertEqual(True, customer_is_old_enough) def test_check_over_age_false(self): customer = Customer("Ed", 20.00, 17) customer_is_old_enough = self.pub.check_age(customer.age) self.assertEqual(False, customer_is_old_enough) def test_customer_can_buy_drink(self): customer = Customer("Colin", 20.00, 25) drink = Drink("Tennants", 3.00, 2) self.pub.customer_can_buy_drink(drink, customer) self.assertEqual(3.00, drink.price) self.assertEqual(17.00, customer.wallet) self.assertEqual(103.00, self.pub.till)
class TestPub(unittest.TestCase): def setUp(self): self.customer1 = Customer('Duncan', 2000, 12) self.customer2 = Customer('Lucinda', 1000, 21) self.customer3 = Customer('Dana', 5000, 18) drink1 = Drink("Guinness", 550) drink2 = Drink("Lager", 250) drink3 = Drink("Wine", 150) self.drinks = [drink1, drink2, drink3] self.pub = Pub("Alpaca Inn", self.drinks, 2000) def test_pub_has_name(self): self.assertEqual("Alpaca Inn", self.pub.name) def test_pub_has_drinks(self): self.assertEqual(3, len(self.drinks)) def test_pub_has_till(self): self.assertEqual(2000, self.pub.till) def test_add_cash_to_till(self): self.pub.add_cash_to_till(self.drinks[0].price) self.assertEqual(2550, self.pub.till) def test_check_customer_age_pass(self): answer = self.pub.check_customer_age(self.customer3) self.assertEqual(True, answer) def test_check_customer_age_pass_fail(self): answer = self.pub.check_customer_age(self.customer1) self.assertEqual(False, answer) def test_serve_customer(self):