def form_post(): journal = request.form['journal'].upper() num_articles = request.form['num_articles'] if pars.valid(journal, num_articles): result = q.enqueue(script.run, journal, num_articles) else: return render_template('input_error.html') return render_template('processing.html')
def form_post(): #https://stackoverflow.com/questions/12277933/send-data-from-a-textbox-into-flask journal = request.form['journal'].upper() num_articles = request.form['num_articles'] if pars.valid(journal, num_articles): script.run(journal, num_articles) else: return render_template('input_error.html') return "Complete!"
def test_input_validation_fails_for_wrong_journal(self): value = pars.valid("mnras", self.test_num_articles) self.assertFalse(value)
def test_input_validation_fails_for_non_number_num_articles(self): value = pars.valid(self.test_journal, "dhj") self.assertFalse(value)
def test_input_validation_fails_for_negative_num_articles(self): value = pars.valid(self.test_journal, "-2") self.assertFalse(value)
def test_input_validation_passes_for_lowercase(self): value = pars.valid(self.test_journal.lower(), self.test_num_articles) self.assertTrue(value)