From 63c3a4d5947240c24632b42ce1c8e7c969ff04e7 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Mon, 29 Jun 2015 21:20:05 +0200 Subject: [PATCH] Test that validaton is happening correctly with correct data. --- test/test.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test.py b/test/test.py index 108fdc6..53f00a5 100644 --- a/test/test.py +++ b/test/test.py @@ -9,6 +9,7 @@ import thread import time import requests import StringIO +import re base_config = { "title": "test", @@ -280,6 +281,31 @@ class WebAppTest(unittest.TestCase): self.assertIn('This form is heavily validated', r.text) self.assertIn('name="string"', r.text) + def testValidateCorrectData(self): + data = { + "form_name": 'validate', + "string": "12345", + "integer": "12", + "float": "0.6", + "date": "2015-01-02", + "text": "1234567890", + "password": "12345", + "radio": "One" + } + + import random + f = file('data.csv', 'w') + for i in range(1024): + f.write(chr(random.randint(0, 255))) + f.close() + + files = {'file': open('data.csv', 'rb')} + r = requests.post("http://localhost:8002/submit", data=data, files=files, auth=self.auth_user) + + r_error = '(.*)' + for match in re.findall(r_error, r.text): + self.assertEquals(match, u'') + def testOutputEscaped(self): """Form with 'escaped' output should have HTML entities escaped""" data = {