Esempio n. 1
0
class TestPub(unittest.TestCase):
    
    def setUp(self):
        self.pub = Pub('The Prancing Pony', 100.00)
        self.drink = Drink("Beer", 5.00, 6)
        self.customer = Customer("TJ", 50.00, 21)

    def test_pub_has_name(self):
        pub_name = self.pub.name
        self.assertEqual('The Prancing Pony', pub_name)

    def test_pub_has_till(self):
        pub_till = self.pub.till
        self.assertEqual(100.00, pub_till)

    def test_drink_count(self):
        count = self.pub.drinks
        self.assertEqual(0, len(count))

    def test_add_to_till(self):
        self.pub.add_to_till(self.drink)
        self.assertEqual(105.00, self.pub.till)

    def test_check_age(self):
        check = self.pub.check_age(self.customer)
        self.assertEqual('What can I get you?', check)

    def test_check_drunkenness_okay(self):
        check = self.pub.check_drunkenness(self.customer)
        self.assertEqual("Yeehaw", check)
    
    def test_check_drunkenness_too_drunk(self):
        self.customer.buy_drink(self.drink)
        check = self.pub.check_drunkenness(self.customer)
        self.assertEqual("You've had enough.", check)
Esempio n. 2
0
class TestPub(unittest.TestCase):
    def setUp(self):

        drink_1 = Drink("beer", 5.00, 2, 120)
        drink_2 = Drink("vodka", 3.00, 3, 30)
        drink_3 = Drink("cocktail", 7.00, 8, 25)
        list_of_drinks = [drink_1, drink_2, drink_3]
        self.pub = Pub("The Prancing Pony", 100.00, list_of_drinks)

    def test_pub_name(self):
        self.assertEqual("The Prancing Pony", self.pub.name)

    def test_pub_till(self):
        self.assertEqual(100.00, self.pub.till)

    def test_drink_availability(self):
        drink_1 = Drink("beer", 5.00, 2, 1)
        self.assertEqual(True, self.pub.drink_available(drink_1))

    def test_pub_drinks_number(self):
        self.assertEqual(3, len(self.pub.drinks))

    def test_age_challange(self):
        customer_2 = Customer("Ed", 6.00, 16)
        self.assertEqual(False, self.pub.age_challange(customer_2))

    def test_drunkenness(self):
        customer_1 = Customer("Mark", 100.00, 33)
        drink_1 = Drink("beer", 5.00, 6, 1)
        customer_1.make_drunk(drink_1)
        customer_1.make_drunk(drink_1)
        self.assertEqual(True, self.pub.check_drunkenness(customer_1))

    def test_add_money_to_till(self):
        drink_1 = Drink("beer", 5.00, 2, 1)
        self.pub.add_money_to_till(self.pub, drink_1)
        self.assertEqual(105.00, self.pub.till)

    def test_stock_count(self):
        self.assertEqual(865, self.pub.stock_count())

    def test_remove_item_from_stock(self):
        drink_1 = Drink("beer", 5.00, 2, 1)
        self.pub.remove_item_from_stock(drink_1)
        self.assertEqual(119, self.pub.check_quantity(drink_1))
Esempio n. 3
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("The Prancing Pony", 100.00)
        self.drink1 = Drink("Gin and Tonic", 2.50, 3, 10)
        self.drink2 = Drink("Rum and Coke", 2.50, 2, 15)
        self.drink3 = Drink("Brandy", 4.00, 5, 8)

    def test_pub_has_name(self):
        self.assertEqual("The Prancing Pony", self.pub.name)

    def test_pub_till_value(self):
        self.assertEqual(100.00, self.pub.till)

    def test_pub_drinks_collection(self):
        self.pub.drinks_stock = ["Gin and Tonic", "Rum and Coke", "Brandy"]
        self.assertEqual(3, len(self.pub.drinks_stock))

    def test_serve_drink(self):
        drink = Drink("Brandy", 4.00, 5, 8)
        self.pub.serve_drink(drink)
        self.assertEqual(104.00, self.pub.till)

    def test_check_age__true(self):
        customer = Customer("Frodo Baggins", 100.00, 50, 0)
        self.pub.check_age(customer)
        self.assertEqual(True, self.pub.check_age(customer))

    def test_check_age__false(self):
        customer = Customer("Peregrin Took", 80.00, 28, 0)
        self.pub.check_age(customer)
        self.assertEqual(False, self.pub.check_age(customer))

    def test_check_drunkenness__true(self):
        customer = Customer("Frodo Baggins", 100.00, 50, 0)
        self.pub.check_drunkenness(customer)
        self.assertEqual(True, self.pub.check_drunkenness(customer))

    def test_check_drunkenness__false(self):
        customer = Customer("Peregrin Took", 80.00, 28, 21)
        self.pub.check_drunkenness(customer)
        self.assertEqual(False, self.pub.check_drunkenness(customer))

    def test_check_stock_level(self):
        drink1 = Drink("Gin and Tonic", 2.50, 3, 10)
        self.assertEqual(10, drink1.stock_level)

    def test_check_total_stock_level(self):
        self.drinks_stock = [self.drink1, self.drink2, self.drink3]
        self.pub.check_total_stock_level(self.drinks_stock)
        self.assertEqual(33,
                         self.pub.check_total_stock_level(self.drinks_stock))

    def test_check_total_stock_price(self):
        self.drinks_stock = [self.drink1, self.drink2, self.drink3]
        self.pub.check_total_stock_price(self.drinks_stock)
        self.assertEqual(94.50,
                         self.pub.check_total_stock_price(self.drinks_stock))

    def test_serve_food(self):
        food = Food("Second Breakfast", 1.50, 2)
        self.pub.serve_food(food)
        self.assertEqual(101.50, self.pub.till)

    def test_at_the_bar__true(self):
        drink = self.drink1
        customer = Customer("Peregrin Took", 80.00, 31, 19)
        self.pub.at_the_bar(drink, customer)
        self.assertEqual(102.50, self.pub.till)

    def test_at_the_bar__false(self):
        drink = self.drink1
        customer = Customer("Peregrin Took", 80.00, 28, 21)
        self.pub.at_the_bar(drink, customer)
        self.assertEqual(100.00, self.pub.till)