def delete(id): if "username" in session: user = get_logged_in_user() message = delete_dessert(user, id) return index() else: dessert = Dessert.query.get(id) return render_template('details.html', user=None, dessert=dessert, error="You must be logged in to delete a dessert.")
def test_delete_nonexistent_dessert(): random_id = 394812018 # I'm pretty sure a dessert by this ID doesn't exist message = delete_dessert(random_id) assert message == 'Dessert not found'
def test_delete_dessert(): dessert = create_dessert('test', 0, 0) message = delete_dessert(dessert.id) assert message == 'Dessert test deleted'