class SimpleListTestCase(unittest.TestCase): def setUp(self): name = "Test" self.item = "Bread" self.test_list = ShoppingList(name) def test_empty_list(self): self.assertEqual(self.test_list.shopping_list, []) def test_standard_text_empty_list(self): self.assertEqual(self.test_list.text, "") def test_single_item_list(self): self.test_list.shopping_list.append(self.item) self.assertEqual(self.test_list.shopping_list, ['Bread']) def test_print_ask_empty_list(self): out = self.test_list.print_ask() self.assertEqual(out, "What should we take from the store?") def test_print_ask_items_on_list(self): self.test_list.shopping_list.append(self.item) out = self.test_list.print_ask() self.assertEqual(out, "What else should we take from the store?")
def share_my_list(): '''share my list by putting its name in a common data structure''' if request.method == 'POST': result = request.form items_share = result['item'] new_share_instance = ShoppingList() new_share_instance.shared_shopping_list_container(items_share) flash('successfully shared your shopping list') return render_template('share_my_list.html') else: flash('Failed to share your shopping list') return render_template('share_my_list.html')
def test_create_view_shoppingList(self): print("test_create_view_shoppingList") self.walmart_sl = ShoppingList('Walmart', '') self.costco_sl = ShoppingList('Costco', '') self.fiesta_sl = ShoppingList('Fiesta', '') self.sprouts_sl = ShoppingList('Sprouts', '') #self.sl.set_storenames('Walmart','') self.walmart_sl.add_groceryitem(GroceryItem('Milk', 2, 1)) self.walmart_sl.add_groceryitem(GroceryItem('Egg', 2, 10)) self.walmart_sl.add_groceryitem(GroceryItem('Nuts', 2, 2)) self.walmart_sl.add_groceryitem(GroceryItem('Chicken', 2, 1)) self.costco_sl.add_groceryitem(GroceryItem('Paper', 2, 1)) self.costco_sl.add_groceryitem(GroceryItem('Plates', 2, 10)) self.costco_sl.add_groceryitem(GroceryItem('Napkins', 2, 2)) self.costco_sl.add_groceryitem(GroceryItem('Chips', 2, 1)) self.fiesta_sl.add_groceryitem(GroceryItem('Milk', 2, 1)) self.fiesta_sl.add_groceryitem(GroceryItem('Juice', 2, 10)) self.fiesta_sl.add_groceryitem(GroceryItem('Potato', 2, 2)) self.fiesta_sl.add_groceryitem(GroceryItem('Mango', 2, 1)) self.sprouts_sl.add_groceryitem(GroceryItem('Sugar', 2, 1)) self.sprouts_sl.add_groceryitem(GroceryItem('Salt', 2, 10)) self.sprouts_sl.add_groceryitem(GroceryItem('Chicken', 2, 2)) self.sprouts_sl.add_groceryitem(GroceryItem('Fish', 2, 1)) print("=================================") self.walmart_sl.view_groceryitem() print("=================================") self.costco_sl.view_groceryitem() print("=================================") self.fiesta_sl.view_groceryitem() print("=================================") self.sprouts_sl.view_groceryitem() self.fiesta_sl.get_itemprice('Juice') print("=================================") self.walmart_sl.remove_groceryitem('Milk') self.walmart_sl.remove_groceryitem('Chicken') self.walmart_sl.view_groceryitem()
elif intentname == user_intent("showShoppingList"): result_sentence = shoppinglist.show() hermes.publish_end_session(intent_message.session_id, result_sentence) elif intentname == user_intent("sendShoppingList"): result_sentence = shoppinglist.send() hermes.publish_end_session(intent_message.session_id, result_sentence) def intent_not_recognized_callback(hermes, intent_message): configure_message = dialogue.DialogueConfiguration().disable_intent( user_intent("confirmShoppingList")) hermes.configure_dialogue(configure_message) shoppinglist.wanted_intents = [] hermes.publish_end_session({ 'sessionId': intent_message.session_id, 'text': "Die Einkaufsliste wurde nicht gelöscht." }) if __name__ == "__main__": config = read_configuration_file("config.ini") shoppinglist = ShoppingList(config) with Hermes("localhost:1883") as h: h.subscribe_intents(intent_callback) h.subscribe_intent_not_recognized(intent_not_recognized_callback) h.start()
screenManager = ScreenManager() #Adding singUp screen screenManager.add_widget(Login(name="userlogin")) screenManager.add_widget(SignUp(name="signup")) screenManager.add_widget(HomeScreen(name="homescreen")) screenManager.add_widget(Profile(name="profile")) screenManager.add_widget(Inventory(name="inventory")) screenManager.add_widget(Trends(name="trends")) screenManager.add_widget(ShoppingList(name="shoppinglist")) screenManager.add_widget(ItemShare(name="shareitems")) screenManager.add_widget(ManagePL(name="managepl")) screenManager.add_widget(EditCreateProfile(name="editcreateprofile")) screenManager.add_widget(SetupEditNotification(name="setupeditnotification")) screenManager.add_widget(UpdatePersonalRecipe(name="updatepersonalrecipe")) screenManager.add_widget(Recipe(name="recipes")) screenManager.add_widget(AddRecipe(name="addrecipe"))
def setUp(self): name = "Test" self.item = "Bread" self.test_list = ShoppingList(name)
'''Main flask app file for the Shopping list application challenge''' from flask import Flask, redirect, url_for, request, render_template, \ session, flash from person import Person from sharelist import ShareList from shoppinglist import ShoppingList app = Flask(__name__) app.secret_key = 'dfkdfjnhfubvhppnhjr' this_person = Person() this_shoppinglist = ShoppingList() this_sharelist = ShareList() @app.route('/add_shopping_list_item', methods=['POST', 'GET']) def add_shopping_list_item(): '''renders the html file of adding an item to a shopping list''' if request.method == 'GET': in_list = request.args['adds'] session['added_list'] = in_list return render_template('add_shopping_list_item.html', records=in_list) elif request.method == 'POST': result = request.form in_list = session['added_list'] in_item = result['list'] # add shopping list as dictionary key and in_list items # as items in the dictionary itemsdictionary = this_shoppinglist.add_items() my_items_dict = itemsdictionary[in_list] # yields a list my_items_dict.append(in_item) new_items_dic = {in_list: my_items_dict} itemsdictionary.update(new_items_dic)