Exemple #1
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("The Prancing Pony", 100.00, "Pint of Bree Best")
        self.drink = Drink("Pint of Bree Best", 3.00, 10)
        self.customer = Customer("The Gaffer", 20, 50, 0, 0)

    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_pub_has_drinks(self):
        self.assertEqual("Pint of Bree Best", self.pub.drink)

    def test_money_added_to_till(self):
        self.assertEqual(103, self.pub.add_money_to_till(self.drink))

    def test_can_serve_customer(self):
        self.assertEqual(
            True,
            self.pub.can_serve_customer(self.customer.age,
                                        self.customer.drunkeness))

    def test_customer_has_drunkeness(self):
        self.assertEqual(0, self.customer.drunkeness)

    def test_sell_drink_to_customer(self):
        self.assertEqual(1, self.pub.sell_drink_to_customer(self.customer))
Exemple #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))
Exemple #3
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("The Prancing Pony", 100.00)
        self.drink1 = Drink("Lambrini", 1.80)
        # self.pub.inventory = [
        #     {"Lambrini":{
        #         "stock_count": 100,
        #         "item_price": 1.80,
        #         "alcohol_level": 6.0}
        #     },
        #     {"Lager":{
        #         "stock_count": 100,
        #         "item_price": 3.50,
        #         "alcohol_level": 3.8}
        #     },
        #     {"Vodka":{
        #         "stock_count": 100,
        #         "item_price": 2.50,
        #         "alcohol_level": 40}
        #     }
        # ]

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

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

    def test_pub_has_drinks(self):
        self.pub.add_inventory(self.drink1)
        self.assertEqual(1, len(self.pub.inventory))

    # MVP test 4

    def test_pub_has_money_from_sale(self):
        self.pub.add_money_to_till(self.drink1)
        self.assertEqual(101.80, self.pub.till)

    def test_pub_can_sell_drink(self):
        customer1 = Customer("John", 100, 21)
        drink2 = Drink("Lager", 4.50)
        self.pub.sell_drink(customer1, drink2)
        self.assertEqual(95.50, customer1.wallet)
        self.assertEqual(104.50, self.pub.till)
Exemple #4
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("The Prancing Pony", 100.00)

    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_pub_has_drinks_list(self):
        drink_1 = Drinks("Stella", 3.50)
        self.pub.add_drink_to_menu(drink_1)
        self.assertEqual(1, self.pub.menu_length())

    def test_add_to_till(self):
        self.pub.add_money_to_till(10.00)
        self.assertEqual(110.00, self.pub.till)

    def test_get_drink_price(self):
        drink_1 = Drinks("Stella", 3.50)
        self.pub.add_drink_to_menu(drink_1)
        price = self.pub.get_drink_price("Stella")
        self.assertEqual(3.50, price)

    def test_sell_drink_to_customer_wallet(self):
        drink_1 = Drinks("Stella", 3.50)
        customer = Customer("Frodo Baggins", 50, 30.00)
        self.pub.add_drink_to_menu(drink_1)
        self.pub.sell_drink_to_customer(customer, "Stella")
        self.assertEqual(26.50, customer.wallet)

    def test_sell_drink_to_customer_till(self):
        drink_1 = Drinks("Stella", 3.50)
        customer = Customer("Frodo Baggins", 50, 30.00)
        self.pub.add_drink_to_menu(drink_1)
        self.pub.sell_drink_to_customer(customer, "Stella")
        self.assertEqual(103.50, self.pub.till)
class TestPub(unittest.TestCase):
    
    def setUp(self):
        self.pub = Pub("Duke's Corner", 100.00)
        self.drink_1 = Drink("Tennents", 3.40, 3.5)
        self.drink_2 = Drink("Wine", 7.50, 12)
        self.customer_1 = Customer("Harrison", 22, 10.00)

        self.pub.add_drink_to_pub(self.drink_1)
        self.pub.add_drink_to_pub(self.drink_2)

    def test_pub_has_name(self):
        self.assertEqual("Duke's Corner", self.pub.name)

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

    def test_pub_has_drinks_list(self):
        self.assertEqual(type([]),type(self.pub.drinks))

    def test_pub_has_drinks(self):
        self.assertEqual(2, len(self.pub.drinks))

    def test_add_money_to_till(self):
        self.pub.add_money_to_till(self.drink_2.price)
        self.assertEqual(107.50, self.pub.till)

    def test_remove_drink_from_pub(self):
        self.pub.remove_drink_from_pub(self.drink_1)
        self.assertEqual(1, len(self.pub.drinks))
    
    def test_sell_drink(self):
        self.pub.sell_drink(self.drink_1, self.drink_1.price, self.customer_1.age)
        self.assertEqual(1, len(self.pub.drinks))
        self.assertEqual(103.40, self.pub.till)
    
    def test_age_check(self):
        result = self.pub.age_check(self.customer_1.age)
        self.assertEqual("OK to serve", result)
Exemple #6
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("Ox", 100.00)
        self.drink_1 = Drink("Tennents", 3.40)
        self.drink_2 = Drink("Wine", 7.50)

    def test_pub_has_name(self):
        self.assertEqual("Ox", self.pub.name)

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

    def test_pub_has_empty_drinks_list(self):
        self.assertEqual(0, len(self.pub.drinks))

    def test_pub_has_drinks(self):
        self.pub.add_drink_to_pub(self.drink_1)
        self.pub.add_drink_to_pub(self.drink_2)
        self.assertEqual(2, len(self.pub.drinks))

    def test_add_money_to_till(self):
        self.pub.add_money_to_till(self.drink_2.price)
        self.assertEqual(107.50, self.pub.till)

    def test_remove_drink_from_pub(self):
        self.pub.add_drink_to_pub(self.drink_1)
        self.pub.add_drink_to_pub(self.drink_2)
        self.pub.remove_drink_from_pub(self.drink_1)
        self.assertEqual(1, len(self.pub.drinks))

    def test_sell_drink(self):
        self.pub.add_drink_to_pub(self.drink_1)
        self.pub.add_drink_to_pub(self.drink_2)
        self.pub.sell_drink(self.drink_1, self.drink_1.price)
        self.assertEqual(1, len(self.pub.drinks))
        self.assertEqual(103.40, self.pub.till)
Exemple #7
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("The Prancing Pony", 100.00, "Kronenburg")

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

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

    def test_pub_has_drinks(self):
        self.assertEqual("Kronenburg", self.pub.pub_drink)

    def test_money_added_to_till(self):
        drink = Drink("Kronenburg", 3)
        self.assertEqual(103, self.pub.add_money_to_till(drink))
        # define function test.
        # define what result we want to see pub till = 103.
        # inside assertEqual () add integer, and function to call from pub class
        # self.pub tells the unit test to access the till in the Pub class and call the till with the value stored in Drink.

    def test_age_verification(self):
        customer = Customer("John", 20, 18)
        self.assertEqual(True, self.pub.check_age(customer))