From 0b14ef82d4058925e7e9db22038777d4654e8199 Mon Sep 17 00:00:00 2001 From: Robert Robinson Date: Tue, 15 Sep 2015 10:05:53 -0600 Subject: 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. --- tests/test_stanza_xep_0004.py | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests') 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): """) + 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, """ + + + + + + + + username@example.org + + + + + """) + + 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, """ + + + + + + + + """) + suite = unittest.TestLoader().loadTestsFromTestCase(TestDataForms) -- cgit v1.2.3