From a9b7f811720a1b693cf0b5b45e718215cf95eddd Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Sat, 4 Jul 2015 13:31:57 +0200 Subject: [PATCH] Test proper validation of checkbox. --- test/test.py | 7 +++++++ test/test_formdefinition_validate.json | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/test.py b/test/test.py index d76a34e..9fe35d6 100644 --- a/test/test.py +++ b/test/test.py @@ -220,6 +220,13 @@ class FormDefinitionTest(unittest.TestCase): self.assertNotIn('val_checkbox', errors) self.assertEquals(values['val_checkbox'], 'on') + def testValidateCheckboxDefaultOn(self): + fd = self.fc.get_form_def('test_val_checkbox_on') + form_values = {"val_checkbox_on": 'off'} + errors, values = fd.validate(form_values) + self.assertNotIn('val_checkbox_on', errors) + self.assertEquals(values['val_checkbox_on'], 'off') + def testValidateCheckboxInvalid(self): fd = self.fc.get_form_def('test_val_checkbox') form_values = {"val_checkbox": 'true'} diff --git a/test/test_formdefinition_validate.json b/test/test_formdefinition_validate.json index 5cbd0bd..043516f 100644 --- a/test/test_formdefinition_validate.json +++ b/test/test_formdefinition_validate.json @@ -98,6 +98,20 @@ } ] }, + { + "name": "test_val_checkbox_on", + "title": "test_val_checkbox_on", + "description": "description", + "script": "test.sh", + "fields": [ + { + "name": "val_checkbox", + "title": "field", + "type": "checkbox", + "value": true + } + ] + }, { "name": "test_val_text", "title": "title",