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)
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)
def get_drinklist(self): eg_drink = Drink("Coke can") drinklist = [] for key, value in eg_drink._drink_prices.items(): drinklist.append(key) return drinklist
def test_sugar(self, input_details): # arrange input_details.side_effect = [2] expected = "with sugar" # act actual = d.milk_sugar() # assert self.assertEqual(expected, actual)
def test_size_small(self, input_details): # arrange input_details.side_effect = [2] expected = "small" # act actual = d.size() # assert self.assertEqual(expected, actual)
def test_size_large(self, input_details): # arrange input_details.side_effect = [1] expected = "large" # act actual = d.size() # assert self.assertEqual(expected, actual)
def test_straight_up(self, input_details): # arrange input_details.side_effect = [3] expected = "-" # act actual = d.milk_sugar() # assert self.assertEqual(expected, actual)
def test_milk(self, input_details): # arrange input_details.side_effect = [1] expected = "extra milk" # act actual = d.milk_sugar() # assert self.assertEqual(expected, actual)
def test_unique(self): # arrange TestDrink = d.Drink("Test Type", "Test Name", "Test Details", "Test Price") test_list = [TestDrink, TestDrink] expected = ["Test Name"] # act actual = r.unique(test_list, "Test Type") # assert self.assertEqual(expected, actual)
def test_unique(self): # arrange db = Mock(Database) MockApp = app.App(db) TestDrink = d.Drink("Test Type","Test Name","Test Details","Test Price") test_list = [TestDrink, TestDrink] expected = ["Test Name"] # act actual = MockApp.unique(test_list,"Test Type") # assert self.assertEqual(expected,actual)
class TestDrinks(unittest.TestCase): def setUp(self): self.my_awesome_drink = Drink("Mojito", 450, "Cocktail") def test_drink_has_name(self): self.assertEqual("Mojito", self.my_awesome_drink.name) def test_drink_has_price(self): self.assertEqual(4.50, self.my_awesome_drink.price()) def test_drink_has_type(self): self.assertEqual("Cocktail", self.my_awesome_drink.type)
def drinks(ID): drinklist = system.get_drinklist() if request.method == 'POST': if (system.get_order(int(ID)) == None): system.new_order(int(ID)) for drink in drinklist: for i in range(int(request.form[drink])): system.add_to_order(Drink(drink), int(ID)) return render_template('item_confirm.html', item="Drinks", ID=ID) return render_template('drinks.html', drinklist=drinklist, ID=ID)
def setUp(self): self.my_awesome_drink = Drink("Mojito", 450, "Cocktail")
def test_increase_drunkenness(self): drink = Drink("Gin and Tonic", 2.50, 3, 10) self.customer3.increase_drunkenness(drink) self.assertEqual(3, self.customer3.drunkenness)
def test_buy_drink(self): drink = Drink("Brandy", 4.00, 5, 8) self.customer2.buy_drink(drink) self.assertEqual(46.00, self.customer2.wallet)
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_check_stock_level(self): drink1 = Drink("Gin and Tonic", 2.50, 3, 10) self.assertEqual(10, drink1.stock_level)
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 setUp(self): self.drinks = Drink("Lambrini", 1.80)
def setUp(self): self.drinks = Drink("Tennants", 3.00, 2)
def setUp(self): self.customers = Customer("Colin", 20.00, 25) self.drink = Drink("Tennents", 3.00, 2)
def root(self): while True: clear_screen() print(welcome()) selection = menu.main_menu() if selection.lower() == "p": clear_screen() selection = menu.people_menu() if selection.lower() == "v": clear_screen() print_data.print_table("people", person) # test elif selection.lower() == "s": clear_screen() print_data.print_table("people", person) search_term = getNonBlankInput( "Enter search term: \nor [Q]uit: ", "Enter a valid name: ") if search_term == "q": self.return_to_menu() else: results = f.search_person(search_term, person) print_data.print_table("results", results) elif selection.lower() == "a": clear_screen() first_name = getNonBlankInput( "Enter first name \nor [Q]uit: ", "Enter a valid name: ") if first_name == "q": self.return_to_menu() else: last_name = getNonBlankInput( "Enter last name \nor [Q]uit: ", "Enter a valid name: ") if last_name == "q": self.return_to_menu() else: age = getValidIntegerInput( "Enter age \nor [Q]uit: ", "Enter a valid age: ") if age == "q": self.return_to_menu() p.add_person(db, person, first_name, last_name, age) elif selection.lower() == "d": clear_screen() print_data.print_table("people", person) del_id = getValidIntegerInput( "Which ID do you wish to delete? \nor [Q]uit: ", "Enter a valid ID from the list: ") if del_id == "q": self.return_to_menu() else: try: index = p.identify_item_in_list(del_id, person) person.pop(index) db.delete_person(del_id) # fix except: print("ID not found in the database.") self.return_to_menu() elif selection.lower() == "e": clear_screen() self.root() else: print("Invalid selection returning to main menu") menu.return_to_menu() # test clear_screen() elif selection.lower() == "d": clear_screen() selection = menu.drinks_menu() if selection.lower() == "v": clear_screen() # load drink menus # print drink menus print_data.print_table("Hot Drinks", self.unique(drink, "Hot")) # test print_data.print_table("Soft Drinks", self.unique(drink, "Soft")) # test print_data.print_table("Alcoholic Drinks", self.unique(drink, "Alcoholic")) # test elif selection.lower() == "a": clear_screen() drink_type = self.drink_type() print_data.print_table(f"{drink_type} Drinks", self.unique(drink, drink_type)) d.make_drink(db, drink, drink_type) elif selection.lower() == "d": clear_screen() drink_type = self.drink_type() print_data.print_table(f"{drink_type} Drinks", self.unique(drink, drink_type)) del_drink = getNonBlankInput( "Which drink do you wish to delete? \nor [Q]uit ", "Enter a valid drink name: ") try: for item in drink: if item.drink_name == del_drink: drink.remove(item) db.delete_drink("drink", del_drink) except: print("Invalid selection returning to main menu") elif selection.lower() == "e": clear_screen() self.root() else: print("Invalid selection returning to main menu") menu.return_to_menu() # test clear_screen() elif selection.lower() == "r": clear_screen() selection = menu.rounds_menu() if selection.lower() == "v": orders = db.load_all("round") print_data.print_dictionary("Latest Round", orders) elif selection.lower() == "s": clear_screen() selection = menu.round_search_menu() if selection == "1": print_data.print_table("people", person) person_id = getValidIntegerInput( "Enter person ID \nor [Q]uit: ", "Enter a valid ID from the list: ") if person_id == "q": self.return_to_menu() else: clear_screen() select_id = p.identify_item_in_list( int(person_id), person) person_object = person[select_id] search_results = Database.search_rounds( db, f"{person_object.first_name} {person_object.last_name}", None) print_data.print_dictionary( "Search Results", search_results) elif selection == "2": date = getValidDateInput( "Enter search date (YYYY-MM-DD) \nor [Q]uit: ", "Invalid date entry.\nEnter search date (YYYY-MM-DD): " ) if date == "q": self.return_to_menu() else: search_results = Database.search_rounds( db, None, date) print_data.print_dictionary( "Search Results", search_results) # elif selection == 3: # print("Under construction") else: print("Invalid selection returning to main menu") elif selection.lower() == "c": clear_screen() round_options = person print_data.print_table("Possible Drinkers", round_options) self.create_round(round_options) menu.return_to_menu() elif selection.lower() == "e": clear_screen() self.root() else: print("Invalid selection returning to main menu") menu.return_to_menu() # test clear_screen() elif selection.lower() == "e": db.update_favourites() clear_screen() print(bye_mate()) time.sleep(1) clear_screen() exit() else: print("Invalid selection. Have another go...") self.return_to_menu()
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)
def setUp(self): self.customer = Customer("Katie", 50.00, 28) self.drink1 = Drink("Lambrini", 1.80)
def setUp(self): self.my_amazing_bar = Bar("My Amazing Bar", "Edinburgh") self.my_awesome_drink = Drink("Screwdriver", 899, "Cocktail")
def setUp(self): self.pub = Pub("The Prancing Pony", 100.00) self.drink1 = Drink("Lambrini", 1.80)
def setUp(self): 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)