Exemplo n.º 1
0
class TestCustomer(unittest.TestCase):

    def setUp(self):
        self.customer = Customer("Gordon", 100, 25)
        self.customer_2 = Customer("Lina", 100, 17)
        self.pub = Pub("The Prancing Pony", 100)
        self.drink = Drink("Tennents Lager", 5, 10)

    def test_customer_has_name(self):
        self.assertEqual("Gordon", self.customer.name)

    def test_customer_has_wallet(self):
        self.assertEqual(100, self.customer.wallet)

    def test_customer_can_buy_drink(self):
        self.customer.customer_buys_drink(self.drink, self.pub)
        self.assertEqual(95, self.customer.wallet)
        self.assertEqual(105, self.pub.till)

    def test_customer_over_18(self):
        self.assertEqual(True, self.pub.check_customer_age(self.customer.age))

    def test_customer_under_18(self):
        self.assertEqual(
            False, self.pub.check_customer_age(self.customer_2.age))
Exemplo n.º 2
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)
Exemplo n.º 3
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.drink_1 = Drink("old fashioned", 5.00, 40)
        self.drink_2 = Drink("hophouse 13", 4.50, 5)
        self.customer_1 = Customer("Fred", 50, 40)
        self.customer_2 = Customer("Jon", 20, 13)
        self.pub = Pub("The Prancing Pony", 100.00,
                       [self.drink_1, self.drink_2])

    # START OF TESTS

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

    def test_pub_has_drinks_list(self):
        self.assertEqual([self.drink_1, self.drink_2], self.pub.drinks_list)

    def test_sell_drink_overage(self):
        self.pub.sell_drink(self.drink_1, self.customer_1)
        self.assertEqual(105, self.pub.till)

    def test_sell_drink_underrage(self):
        self.pub.sell_drink(self.drink_1, self.customer_2)
        self.assertEqual(100, self.pub.till)

    def test_sell_drink_too_drunk(self):
        for _ in range(4):
            self.customer_1.buy_drink(self.drink_1, self.pub)

        self.assertEqual(115, self.pub.till)
Exemplo n.º 4
0
 def test_customer_is_refused_service_underage(self):
     pub = Pub("The Prancing Pony", 100.00)
     drink = Drink("Vodka Martini", 6.50, 3)
     self.customer = Customer("Emily Cullen", 20.00, 17)
     pub.add_drink_to_list(drink)
     self.customer.buy_drink(drink, pub)
     self.assertEqual(100, pub.till)
Exemplo n.º 5
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))
Exemplo n.º 6
0
class TestPub(unittest.TestCase):
    def setUp(self):
        # self.drink = [{"name": "Elven Wine", "price": 9.99}, {"name": "Dwarf Ale", "price": 10.99}]
        drink_1 = Drink("Elven Wine", 9.99, 12)
        drink_2 = Drink("Dwarf Ale", 10.99, 6)
        self.drink = [drink_1, drink_2]
        self.pub = Pub("The Prancing Pony", 100, self.drink)

    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, pub_till)

    def test_increase_till(self):
        self.pub.increase_till(self.drink[0])
        self.assertEqual(109.99, self.pub.till)

    def test_pub_has_drink(self):
        self.assertEqual(2, len(self.drink))

    def test_drink_name(self):
        self.assertEqual("Elven Wine", self.drink[0].name)

    def test_customer_over_age(self):
        self.customer = Customer("Frodo", 20, 12)
        self.assertEqual(False, self.customer.customer_over_age(self.customer))
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
 def setUp(self):
     self.pub = Pub("The Prancing Pony", 100)
     self.customer_1 = Customer("Ben", 10, 18, 0)
     self.customer_2 = Customer("Adam", 1, 12, 0)
     self.drink_1 = Drink("Tennents", 2, 1)
     self.drink_2 = Drink("wine", 4, 2)
     self.drink_3 = Drink("gin", 5, 3)
Exemplo n.º 9
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("Mos Eisley Cantina", 100,
                       ["Jabba Juice", "Spotchka", "Blackroot"])

    def test_name(self):
        self.assertEqual("Mos Eisley Cantina", self.pub.name)

    def test_till(self):
        self.assertEqual(100, self.pub.till)

    def test_drink(self):
        self.assertEqual(
            {
                'name': "Jabba Juice",
                "units": 5,
                "price": 3,
                'name': "Spotchka",
                "units": 10,
                "price": 5,
                'name': "Blackroot",
                "units": 3,
                "price": 2
            }, self.pub.drinks)

    def test_increase_till(self):
        self.pub.increase_till(5)
        self.assertEqual(105, self.pub.till)
Exemplo n.º 10
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub("The Prancing Pony", 100)
        self.customer = Customer("Bruce", 50, 30, 0)
        self.pub.drinks = {
            "Beer": 20,
            "Ginandtonic": 10,
            "Rum": 40,
            "Vodka": 10
        }

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

    def test_pub_has_till(self):
        self.assertEqual(100, self.pub.till)

    def test_check_age_and_drunkenness(self):
        self.pub.check_age_and_drunkenness(self.customer)
        # self.customer.age >= 18
        self.assertEqual(30, self.customer.age)
        self.assertEqual(0, self.customer.drunkenness_level)

    def test_drunkenness_level(self):
        self.assertEqual(0, self.customer.drunkenness_level)
Exemplo n.º 11
0
 def setUp(self):
     self.drink_1 = Drink("old fashioned", 5.00, 40)
     self.drink_2 = Drink("hophouse 13", 4.50, 5)
     self.customer_1 = Customer("Fred", 50, 40)
     self.customer_2 = Customer("Jon", 20, 13)
     self.pub = Pub("The Prancing Pony", 100.00,
                    [self.drink_1, self.drink_2])
Exemplo n.º 12
0
 def setUp(self):
     self.pub = Pub("The prancing pony", 100)
     self.drink = Drink("Beer", 2, 6)
     self.food = Food("Burger", 3, 2)
     self.customer = Customer("name", 10, 21)
     self.underage_customer = Customer("name", 10, 16)
     self.pub.add_stocklist(self.drink)
     self.pub.add_food(self.food)
Exemplo n.º 13
0
 def setUp(self):
     self.pub = Pub("Ox", 100.00)
     self.customer_1 = Customer("Billy", 50.00, 18)
     self.customer_2 = Customer("Jimmy", 50.00, 16)
     self.drink_1 = Drink("Beer", 5.0, 5.5)
     self.drink_2 = Drink("Wine", 7.5, 15.0)
     self.drink_3 = Drink("Spirit", 3.5, 40.0)
     self.drink_4 = Drink("Cocktail", 10.0, 25.0)
Exemplo n.º 14
0
 def setUp(self):
     # this sets up the list with two list items
     self.drink_1 = Drink("Brew Dog", 5)
     self.drink_2 = Drink("Dolce Banana", 15)
     # this says that the two items go in the list
     drinks = [self.drink_1, self.drink_2]
     # this gives values to the parameters to Class pub
     self.pub = Pub("The Prancing Pony", 100.00, drinks)
Exemplo n.º 15
0
 def setUp(self):
     self.pub = Pub("The Lion", 1000)
     self.drink_1 = Drink("Martini", 5, 4)
     self.drink_2 = Drink("Rusty Nail", 6, 10)
     self.drink_3 = Drink("Pinot Grigio", 7, 8)
     self.drinks = [self.drink_1, self.drink_2, self.drink_3]
     self.customer_1 = Customer("Brian", 300, 28)
     self.customer_2 = Customer("Tim", 5, 12)
Exemplo n.º 16
0
    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)
Exemplo n.º 17
0
class TestCustomer(unittest.TestCase):
    def setUp(self):
        self.customer = Customer("Jake", 28, 10000)
        self.customer2 = Customer("Barbera", 47, 20000)
        self.customer3 = Customer("Brooklyn", 17, 600)
        self.pub = Pub("The Pink Truncheon", 100)

        # list_of_customers = [{self.customer = Customer("Jake", 28, 10000)},
        #                      {self.customer2 = Customer("Barbera", 47, 20000)},
        #                      {self.customer3 = Customer("Brooklyn", 17, 600)}

    def test_customer_has_name(self):
        self.customer4 = Customer("Cool customer", 7, 1000000)
        self.assertIsNotNone(self.customer.name, "Customer does not exist")
        self.assertIsNotNone(self.customer2.name, "Customer does not exist")
        self.assertIsNotNone(self.customer3.name, "Customer does not exist")
        # assertIsNotNone(test variable, "Message If test failed")

        ##### Buying a drink #####
        # Take money off customer
        # Add money to pubs till
        # Give them a drink
        # Add to pissed level

    def test_take_money_off_customer(self):
        drink = self.pub.find_drink_by_name("fosters")
        monies = drink["price"]
        self.customer.take_money_off_customer(monies)
        self.assertEqual(9500, self.customer.wallet)
        # take_money_off_customer(self, customer, monies):

    def test_increase_fun(self):
        drink = self.pub.find_drink_by_name("corona")
        units = drink["units"]
        self.customer.increase_fun(units)
        self.assertEqual(2, self.customer.drunk_level)
        # def increase_fun(self, units):

    def test_buy_drink(self):
        drink = self.pub.find_drink_by_name("tennents")
        self.customer.buy_drink(drink)
        self.assertEqual(9600, self.customer.wallet)
        self.assertEqual(1, self.customer.drunk_level)

    # {"name" : "tennents", "price": 400, "units": 1}
    # def buy_drink(self, drinks):

    #### MVP ####


#  - A `Customer` should be able to buy a `Drink` from the `Pub`,
# reducing the money in its `wallet` and increasing the money in the
# `Pub`'s `till`

#### Extensions ####
#   - Add `alcohol_level` to the Drink, and a `drunkenness` level to the
#         `Customer`. Every time a `Customer` buys a drink,
#          the `drunkenness` level should go up by the `alcohol_level`
Exemplo n.º 18
0
 def setUp(self):
     self.pub = Pub("The Prancing Pony", 100.00)
     self.customer_1 = Customer("Mark", 10.00, 33, 0)
     self.customer_2 = Customer("Andrew", 20.00, 17, 10)
     self.customer_3 = Customer("Steven", 0.00, 37, 20)
     self.drink_1 = Drink("Whisky", 5, 5, 10)
     self.drink_2 = Drink("Punk IPA", 4.50, 1, 10)
     self.food_1 = Food("Pie", 2.75, 5, 10)
     self.food_2 = Food("Crisps", 0.99, 1, 0)
Exemplo n.º 19
0
    def setUp(self):
        self.drink_1=Drink("beer", 3.00, 1, 10)
        self.drink_2=Drink("red wine", 2.00, 2, 8)
        self.drinks=[self.drink_1, self.drink_2]

        self.pub = Pub("The Prancing Pony", 100.00, self.drinks)
        self.customer_1 = Customer("Callum", 10.00, 24, 6)
        self.customer_2 = Customer("John", 5.00, 16, 0)
        self.customer_3 = Customer("James", 15.00, 30, 3)
Exemplo n.º 20
0
 def setUp(self):
     self.pub = Pub("The Prancing Pony", 100.00)
     self.stock = {"beer": 5, "wine": 7, "absinthe": 2}
     self.drink_1 = Drink("wine", 8, 0.12)
     self.drink_2 = Drink("absinthe", 8, 0.8)
     self.food_1 = Food("pizza", 6, 0.4)
     self.customer_1 = Customer("Craig", 20, 18)
     self.customer_2 = Customer("Jack", 20, 18)
     self.customer_3 = Customer("Jack", 20, 17)
Exemplo n.º 21
0
 def setUp(self):
     self.pub = Pub("Ox", 100)
     self.customer = Customer("Jenny", 100)
     self.drink_beer = Drink("Beer", 3)
     self.drink_wine = Drink("Wine", 4)
     self.drink_cider = Drink("Cider", 3)
     self.pub.stock_drink = [
         self.drink_beer, self.drink_wine, self.drink_cider
     ]
Exemplo n.º 22
0
 def setUp(self):
     self.drink_1 = Drink("Guinness", 10, 2)
     self.drink_2 = Drink("Gin", 15, 4)
     self.drink_3 = Drink("Whisky", 20, 6)
     self.BrewDog = Pub("Brewdog_edinburgh", 100,
                        [self.drink_1, self.drink_2, self.drink_3])
     self.customer = Customer("Billy", 200, 45)
     self.customer_2 = Customer("Jane", 5, 30)
     self.customer_3 = Customer("Gerorge", 50, 16)
Exemplo n.º 23
0
 def setUp(self):
     self.pub = Pub("The Prancing Pony", 100)
     self.customer = Customer("Bruce", 50, 30, 0)
     self.pub.drinks = {
         "Beer": 20,
         "Ginandtonic": 10,
         "Rum": 40,
         "Vodka": 10
     }
Exemplo n.º 24
0
    def setUp(self):
        self.customer1 = Customer("Keith", 2000)
        self.customer2 = Customer("John", 2000)

        self.drink1 = Drink("Guinness", 550)
        self.drink2 = Drink("G+T", 400)
        drinks = [self.drink1, self.drink2]

        self.pub = Pub("Red_Lion", 10000, drinks)
Exemplo n.º 25
0
    def setUp(self):
        self.drink_1 = Drink("Mojito", 8.0, 7)
        self.drink_2 = Drink("Pilsen", 6.5, 4)

        self.customer_1 = Customer("Malcolm", 25.0, 28)
        self.customer_2 = Customer("Erika", 30.0, 17)

        drinks = [self.drink_2, self.drink_1]
        self.pub = Pub("JP's", drinks, 500)
Exemplo n.º 26
0
    def setUp(self):
        self.drink_1 = Drink("beer", 2.00, 5)
        self.drink_2 = Drink("wine", 3.00, 10)
        self.drink_3 = Drink("gin", 4.00, 30)

        self.pub = Pub("The Prancing Pony", 100.00)

        self.customer_1 = Customer("Frodo", 10.00, 28, 0)
        self.customer_2 = Customer("Merry", 15.00, 17, 0)
        self.customer_3 = Customer("Pippin", 100.00, 28, 0)
Exemplo n.º 27
0
 def test_customer_refused_service_too_drunk(self):
     pub = Pub("The Prancing Pony", 100.00)
     drink = Drink("Vodka Martini", 6.50, 3)
     pub.add_drink_to_list(drink)
     self.customer.buy_drink(drink, pub)
     self.customer.buy_drink(drink, pub)
     self.customer.buy_drink(drink, pub)
     self.customer.buy_drink(drink, pub)
     self.customer.buy_drink(drink, pub)
     self.customer.buy_drink(drink, pub)
     self.assertEqual(117.50, self.customer.wallet)
Exemplo n.º 28
0
    def setUp(self):
        self.pub = Pub("Ox", 100.00)
        self.drink = Drink("Highland Park 18yr", 6.95, 8)
        self.drink2 = Drink("Rum", 5.50, 4)
        self.drink3 = Drink("Beer", 3.20, 2)

        self.food = Food("Chips and gravy", 3.50, 100)
        
        self.customer1 = Customer("Malcolm", 33, 25.00)
        self.customer2 = Customer("Harrison", 15, 30.00)
        self.customer3 = Customer("Dave", 21, 50.00)
Exemplo n.º 29
0
class TestPub(unittest.TestCase):
    def setUp(self):
        self.pub = Pub('The Dancing Otter', 100)
        self.drink = Drink('hibster beer', 3, 1)
        self.customer = Customer('Robin', 50, 19)

    def test_pub_has_name(self):
        self.assertEqual('The Dancing Otter', self.pub.name)

    def test_drink_sold(self):
        self.pub.drink_sold(self.drink)
        self.assertEqual(103, self.pub.cash)
Exemplo n.º 30
0
    def setUp(self):
        stock = {
            "drinks": [Drink("cosmo", 4.00, 3),
                       Drink("beer", 2.50, 2)],
            "food": [Food("burger", 2.00, 10),
                     Food("hotdog", 2.00, 5)]
        }

        self.pub = Pub("The Prancing Pony", 100.00, stock)
        self.customer = Customer("Bob", 50.00, 30)
        self.drink = self.pub.stock["drinks"][0]
        self.young_customer = Customer("Betty", 20.00, 16)
        self.food = self.pub.stock["food"][1]