def submitNewRecipe(): name = request.args.get('softwareName') ver = request.args.get('version') status = request.args.get('status') normal_db_functions.create_recipe(database_address, name, ver, status) flash('Recipe uploaded successfully') return redirect(url_for('recipes'))
def test_create_recipe(self): normal_db_functions.create_recipe(db_file, "MyRecipe", "7.8.9.4", "In development") conn = sqlite3.connect(db_file) cur = conn.cursor() cur.execute("SELECT * FROM recipes WHERE name = 'MyRecipe' AND version_num = '7.8.9.4' AND status = 'In development'") data = cur.fetchall() if len(data) == 0: self.assertTrue(False) else: self.assertTrue(True)
def test_change_recipe_name(self): normal_db_functions.create_recipe(db_file, "1", "1.2.3.4", "In Dev") normal_db_functions.change_recipe_name(db_file, "1", "1.2.3.4", "Hi") conn = sqlite3.connect(db_file) cur = conn.cursor() cur.execute("SELECT * FROM recipes WHERE name = 'Hi'") data = cur.fetchall() if len(data) == 0: self.assertTrue(False) else: self.assertTrue(True)
def test_change_recipe_status(self): normal_db_functions.create_recipe(db_file, "3", "5.3.2.1", "In Dev") normal_db_functions.change_recipe_status(db_file, "3", "5.3.2.1", "Good") conn = sqlite3.connect(db_file) cur = conn.cursor() cur.execute("SELECT * FROM recipes WHERE status = 'Good'") data = cur.fetchall() if len(data) == 0: self.assertTrue(False) else: self.assertTrue(True)
def test_change_recipe_version_num(self): normal_db_functions.create_recipe(db_file, "2", "4.3.2.1", "In Dev") normal_db_functions.change_recipe_version_num(db_file, "2", "4.3.2.1", "6.7.8.9") conn = sqlite3.connect(db_file) cur = conn.cursor() cur.execute("SELECT * FROM recipes WHERE version_num = '6.7.8.9'") data = cur.fetchall() if len(data) == 0: self.assertTrue(False) else: self.assertTrue(True)
def cloneRecipe(): recipeId = request.form.get('recipeID') recipe = normal_db_functions.lookupRecipe(database_address, recipeId) version_num = recipe['version_num'][:-1] + chr( ord(recipe['version_num'][-1]) + 1) newRecipeId = normal_db_functions.create_recipe(database_address, recipe['name'], version_num, recipe['status']) relationships = normal_db_functions.select_recipe_components( database_address, recipeId) for relationship in relationships: normal_db_functions.create_relationship(database_address, newRecipeId, relationship['componentID']) flash('Recipe Clone successfully') return redirect(url_for('recipes'))