Validate that form values are properly repopulated when there are errors.

pull/7/head
Ferry Boender 10 years ago
parent 07bc8cd88d
commit d063e68e82
  1. 34
      test/test.py
  2. 9
      test/test_webapp.json

@ -405,6 +405,40 @@ class WebAppTest(unittest.TestCase):
self.assertIn('Invalid value for radio button', r.text) self.assertIn('Invalid value for radio button', r.text)
self.assertIn('Invalid value for dropdown', r.text) self.assertIn('Invalid value for dropdown', r.text)
def testValidateRefill(self):
"""
Ensure that field values are properly repopulated if there were any
errors in validation.
"""
data = {
"form_name": 'validate',
"string": "123",
"integer": "12",
"float": "0.6",
"date": "2015-01-02",
"text": "1234567890",
"password": "12345",
"radio": "One",
"checkbox": "on",
"select": "option_b",
}
import random
f = file('data.txt', 'w')
for i in range(1024):
f.write(chr(random.randint(0, 255)))
f.close()
files = {'file': open('data.txt', 'rb')}
r = requests.post("http://localhost:8002/submit", data=data, files=files, auth=self.auth_user)
self.assertIn('value="123"', r.text)
self.assertIn('value="12"', r.text)
self.assertIn('value="0.6"', r.text)
self.assertIn('value="2015-01-02"', r.text)
self.assertIn('>1234567890<', r.text)
self.assertIn('value="12345"', r.text)
self.assertIn('value="on"', r.text)
self.assertIn('selected>Option B', r.text)
def testOutputEscaped(self): def testOutputEscaped(self):
"""Form with 'escaped' output should have HTML entities escaped""" """Form with 'escaped' output should have HTML entities escaped"""

@ -132,6 +132,15 @@
"required": true, "required": true,
"minlen": 5 "minlen": 5
}, },
{
"name": "select",
"title": "A select input field",
"type": "select",
"options": [
["option_a", "Option A"],
["option_b", "Option B"]
]
},
{ {
"name": "checkbox", "name": "checkbox",
"title": "A checkbox input field", "title": "A checkbox input field",

Loading…
Cancel
Save