summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_stanza_xep_0122.py40
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)