summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Robinson <rerobins@gmail.com>2015-09-15 10:05:53 -0600
committerRobert Robinson <rerobins@gmail.com>2015-09-15 10:05:53 -0600
commit0b14ef82d4058925e7e9db22038777d4654e8199 (patch)
treefbbefac28f9b00c0c10f1e1d36e469b61a7ab35a /tests
parent93c705fb3133b27388c0845f925b0615c88414b1 (diff)
downloadslixmpp-0b14ef82d4058925e7e9db22038777d4654e8199.tar.gz
slixmpp-0b14ef82d4058925e7e9db22038777d4654e8199.tar.bz2
slixmpp-0b14ef82d4058925e7e9db22038777d4654e8199.tar.xz
slixmpp-0b14ef82d4058925e7e9db22038777d4654e8199.zip
Add test case for reported and items
Previous stanza test cases didn't have test cases for reported and item field types in forms. This fixes that issue. Modified stanzabase to use an ordered dict so that can guarentee the that 'items' in a form are added after reported. Also updated the set of interfaces that are stored in Form to be a ordered set. Used the order set implementation from: https://code.activestate.com/recipes/576694/ The OrderedSet implementation is licensed under the MIT license and is developed by the same developer of the ordereddict.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stanza_xep_0004.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0004.py b/tests/test_stanza_xep_0004.py
index e8bc6593..b87afb24 100644
--- a/tests/test_stanza_xep_0004.py
+++ b/tests/test_stanza_xep_0004.py
@@ -197,5 +197,52 @@ class TestDataForms(SleekTest):
<x xmlns="jabber:x:data" type="cancel" />
""")
+ def testReported(self):
+ msg = self.Message()
+ form = msg['form']
+ form['type'] = 'result'
+
+ form.add_reported(var='f1', ftype='text-single', label='Username')
+
+ form.add_item({'f1': 'username@example.org'})
+
+ self.check(msg, """
+ <message>
+ <x xmlns="jabber:x:data" type="result">
+ <reported>
+ <field var="f1" type="text-single" label="Username" />
+ </reported>
+ <item>
+ <field var="f1">
+ <value>username@example.org</value>
+ </field>
+ </item>
+ </x>
+ </message>
+ """)
+
+ def testSetReported(self):
+ msg = self.Message()
+ form = msg['form']
+ form['type'] = 'result'
+
+ reported = {'f1': {
+ 'var': 'f1',
+ 'type': 'text-single',
+ 'label': 'Username'
+ }}
+
+ form.set_reported(reported)
+
+ self.check(msg, """
+ <message>
+ <x xmlns="jabber:x:data" type="result">
+ <reported>
+ <field var="f1" type="text-single" label="Username" />
+ </reported>
+ </x>
+ </message>
+ """)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestDataForms)