def add_pitch(uname): title = "Add pitch" form = addPitch() user = User.query.filter_by(username = uname).first() if user is None: abort(404) if form.validate_on_submit(): title = form.title.data categorydata = form.category.data category_id = (Category.get_category_name(categorydata)) description = form.description.data upvotes = 0 downvotes = 0 new_pitch = Pitch(title=title, category_id = category_id, description = description, user = user, upvotes = upvotes, downvotes = downvotes) new_pitch.save_pitch() return redirect(url_for("main.index")) return render_template("addpitch.html", form = form, title = title)
def test_get_category_name(self): db.session.add(self.new_category) db.session.commit() get_id = Category.get_category_name('category') self.assertEqual(get_id.id, 1)
def test_get_category_name(self): self.new_category = Category(category_name = 'category') get_id = Category.get_category_name('category') self.assertEqual(get_id, 1)