diff options
author | Robert Robinson <rerobins@gmail.com> | 2015-09-15 10:09:06 -0600 |
---|---|---|
committer | Robert Robinson <rerobins@gmail.com> | 2015-09-15 10:09:06 -0600 |
commit | 2a127a57a7790626c8a0bb979ec6e10d96e4535d (patch) | |
tree | 0c9fd6677b56050dcd44c7f4c34adaf842fea7b9 /tests | |
parent | 7059400020d21c960b87aa41189b1b26c3776061 (diff) | |
download | slixmpp-2a127a57a7790626c8a0bb979ec6e10d96e4535d.tar.gz slixmpp-2a127a57a7790626c8a0bb979ec6e10d96e4535d.tar.bz2 slixmpp-2a127a57a7790626c8a0bb979ec6e10d96e4535d.tar.xz slixmpp-2a127a57a7790626c8a0bb979ec6e10d96e4535d.zip |
Add test case Reported->Data Form Validation
Add a test case that will verify that reported fields can contain data form validation data.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_stanza_xep_0122.py | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/tests/test_stanza_xep_0122.py b/tests/test_stanza_xep_0122.py index 5576c45f..fca49bbb 100644 --- a/tests/test_stanza_xep_0122.py +++ b/tests/test_stanza_xep_0122.py @@ -16,7 +16,7 @@ class TestDataForms(SleekTest): register_stanza_plugin(xep_0004.FormField, xep_0122.FormValidation) def test_basic_validation(self): - """Testing using multiple instructions elements in a data form.""" + """Testing basic validation setting and getting.""" msg = self.Message() form = msg['form'] field = form.addField(var='f1', @@ -51,7 +51,7 @@ class TestDataForms(SleekTest): self.assertFalse(validation.get_regex()) def test_open_validation(self): - """Testing using multiple instructions elements in a data form.""" + """Testing open validation setting and getting.""" msg = self.Message() form = msg['form'] field = form.addField(var='f1', @@ -85,7 +85,7 @@ class TestDataForms(SleekTest): self.assertFalse(validation.get_regex()) def test_regex_validation(self): - """Testing using multiple instructions elements in a data form.""" + """Testing regex validation setting and getting.""" msg = self.Message() form = msg['form'] field = form.addField(var='f1', @@ -123,7 +123,7 @@ class TestDataForms(SleekTest): self.assertEqual(regex_value, validation.get_regex()) def test_range_validation(self): - """Testing using multiple instructions elements in a data form.""" + """Testing range validation setting and getting.""" msg = self.Message() form = msg['form'] field = form.addField(var='f1', @@ -153,5 +153,37 @@ class TestDataForms(SleekTest): self.assertDictEqual(dict(minimum=str(0), maximum=str(10)), validation.get_range()) + def test_reported_field_validation(self): + """ + Testing adding validation to the field when it's stored in the reported. + :return: + """ + msg = self.Message() + form = msg['form'] + field = form.addReported(var='f1', ftype='text-single', label='Text') + validation = field['validate'] + validation.set_basic(True) + + form.addItem({'f1': 'Some text!'}) + + self.check(msg, """ + <message> + <x xmlns="jabber:x:data" type="form"> + <reported> + <field var="f1" type="text-single" label="Text"> + <validate xmlns="http://jabber.org/protocol/xdata-validate"> + <basic /> + </validate> + </field> + </reported> + <item> + <field var="f1"> + <value>Some text!</value> + </field> + </item> + </x> + </message> + """) + suite = unittest.TestLoader().loadTestsFromTestCase(TestDataForms) |