def test_get_best_preparation_for_bean(self): database.create_tables(self.connection) database.add_bean(self.connection, "Test Bean", "Percolator", 100) database.add_bean(self.connection, "Test Bean", "Espresso", 80) best_preparation = database.get_best_preparation_for_bean(self.connection, "Test Bean") self.assertEqual(best_preparation[2], "Percolator")
def menu(): connection = database.connect() database.create_tables(connection) while (user_input := input(MENU_PROMPT)) != "5": if user_input == "1": name = input("Enter your bean name: ") method = input("Enter how you've prepared it") rating = int(input("Enter your rating score (0-100): ")) database.add_bean(connection, name, method, rating) elif user_input == "2": beans = database.get_all_beans(connection) for bean in beans: print(f"{bean[1]}{bean[2]}{bean[3]}") elif user_input == "3": name = input("Enter bean name to find: ") beans = database.get_beans_by_name(connection, name) for bean in beans: print(f"{bean[1]}{bean[2]}{bean[3]}") elif user_input == "4": name = input("Enter bean name to find: ") best_method = database.get_best_preparation_for_bean(connection, name) print(f"The best preparation method for {name} is {best_method[2]}") elif user_input == "5": pass else: pass
def menu(): connection = database.connect() database.create_tables(connection) user_input = input(MENU_PROMPT) while (user_input != "5"): if user_input == "1": name = input("Enter bean name: ") method = input("Ender how you prepared it: ") rating = int(input("Enter score (0-100): ")) database.add_bean(connection, name, method, rating) elif user_input == "2": beans = database.get_all_beans(connection) for bean in beans: print(f"{bean[1]} ({bean[2]}) - {bean[3]}/100") elif user_input == "3": name = input("Enter bean name: ") beans = database.get_beans_by_name(connection, name) for bean in beans: print(f"{bean[1]} ({bean[2]}) - {bean[3]}/100") elif user_input == "4": name = input("Enter bean name: ") best_method = database.get_best_preparation_for_bean( connection, name) print( f"The best preparation method for {name} is : {best_method[2]}" ) else: print("Invalid input or exit. Try again :)") user_input = input(MENU_PROMPT)
def menu(): connection = connect() create_table(connection) user_input = input(MENU_PROMPT) while user_input != "5": if user_input == "1": name = input("Enter Bean Name: ") method = input("Enter How you've Prepared It: ") rating = int(input("Enter Your Rating Score: ")) add_bean(connection, name, method, rating) elif user_input == "2": beans = get_all_beans(connection) for bean in beans: print(f"{bean[1]} {bean[2]} {bean[3]}") elif user_input == "3": name = input("Enter bean Name to find: ") beans = get_beans_by_name(connection, name) for bean in beans: print(f"{bean[1]} {bean[2]} {bean[3]}") elif user_input == "4": name = input("Enter Bean name to find: ") best_method = get_preparation_for_beans(connection, name) print( f"The Best Preparation method for {name} is: {best_method[2]}") user_input = input(MENU_PROMPT)
def test_get_all_beans(self): database.create_tables(self.connection) database.add_bean(self.connection, "Test Bean", "Percolator", 100) beans = database.get_all_beans(self.connection) self.assertEqual(beans[0][1], "Test Bean") self.assertEqual(beans[0][2], "Percolator") self.assertEqual(beans[0][3], 100)
def test_get_multiple_beans_by_name(self): database.create_tables(self.connection) database.add_bean(self.connection, "Test Bean", "Percolator", 100) database.add_bean(self.connection, "Test Bean", "Espresso", 80) beans = database.get_beans_by_name(self.connection, "Test Bean") self.assertEqual(beans[0][1], "Test Bean") self.assertEqual(beans[1][1], "Test Bean") self.assertEqual(beans[0][2], "Percolator") self.assertEqual(beans[1][2], "Espresso")
def test_database_insert_beans(self): database.create_tables(self.connection) database.add_bean(self.connection, "Test Bean", "Percolator", 100) with self.connection: cursor = self.connection.execute("SELECT * FROM beans;") results = cursor.fetchone() self.assertEqual(results[1], "Test Bean") self.assertEqual(results[2], "Percolator") self.assertEqual(results[3], 100)
def menu(): connection=database.connect() database.create_tables(connection) # user_input=input(MENU_PROMPT) while (user_input :=input(MENU_PROMPT))!='5': if user_input=='1': name,method,rating=input('please enter name,method and rating(between 0-100) resp').split(",") database.add_bean(connection, name, method, int(rating)) elif user_input=='2': beans=database.get_all_beans(connection) for bean in beans: print(bean) elif user_input=='3': name=input('enter name u want to find') bin=database.get_beans_by_name(connection, name) print(bin) elif user_input=='4': name=input('enter name u want to get') name=database.get_best_prep_for_bean(connection, name) print(name) else: print('invalid input')
def menu(): connection = database.connect() database.create_table(connection) inp = 1 while (inp): inp = input(menu_prompt) if inp == '1': name = input("Enter bean name: ") method = input("How you prepared the bean: ") rating = int(input("Enter your rating Score: ")) database.add_bean(connection, name, method, rating) elif inp == '2': beans = database.get_all_beans_func(connection) for i in beans: print(f" {i[1]} ({i[2]}) - {i[3]}/100 ") elif inp == '3': name = input("Enter the bean name to find it: ") beans = database.get_beans_by_name_func(connection, name) for i in beans: print(f" {i[1]} ({i[2]}) - {i[3]}/100 ") elif inp == '4': name = input("Enter bean name: ") best_method = database.get_best_preperation_for_bean_func( connection, name) print( f"The best preperation method for {name} is {best_method[2]} ") elif inp == '5': exit(1) else: print("Enter a valied Input")
def prompt_add_new_bean(connection): name = input("Enter bean name: ") method = input("Enter preparation method: ") rating = int(input("Enter rating: ")) database.add_bean(connection, name, method, rating)
def prompt_add_new_bean(connection): name = input("Enter bean name: ") method = input("Enter how you've prepared it: ") rating = int(input("Enter your rating score (0-100): ")) database.add_bean(connection, name, method, rating)