diff --git a/test/test.py b/test/test.py index ee1bd95..573e188 100644 --- a/test/test.py +++ b/test/test.py @@ -405,6 +405,40 @@ class WebAppTest(unittest.TestCase): self.assertIn('Invalid value for radio button', 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): """Form with 'escaped' output should have HTML entities escaped""" diff --git a/test/test_webapp.json b/test/test_webapp.json index 7a2a6a2..3312e14 100644 --- a/test/test_webapp.json +++ b/test/test_webapp.json @@ -132,6 +132,15 @@ "required": true, "minlen": 5 }, + { + "name": "select", + "title": "A select input field", + "type": "select", + "options": [ + ["option_a", "Option A"], + ["option_b", "Option B"] + ] + }, { "name": "checkbox", "title": "A checkbox input field",