def index(): if request.method=='GET': return render_template("home.html",titles=database.get_stories()) if request.method=='POST': if(request.form["button"]=="Submit"): database.add_story(str(request.form['title'])) return render_template("home.html",titles=database.get_stories()) elif (request.form["button"]=="Go To Story"): title=str(request.form['select']) assert title!="" return render_template("story.html",title=title,comments=database.get_comments(title)) elif (request.form["button"]=="Delete Story"): title=str(request.form['select']) database.delete_story(title) return render_template("home.html",titles=database.get_stories())
def test_delete_story(self): database.add_story("new story") database.delete_story("new story") self.assertEqual(0,len(database.get_stories()))
def tearDown(self): for title in database.get_stories(): database.delete_story(title) print database.get_stories()