From 93c705fb3133b27388c0845f925b0615c88414b1 Mon Sep 17 00:00:00 2001 From: Robert Robinson Date: Mon, 14 Sep 2015 17:00:53 -0600 Subject: Fix xep_0050 changes after form refactor. --- sleekxmpp/plugins/xep_0004/stanza/form.py | 9 ++++----- tests/test_stream_xep_0050.py | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/sleekxmpp/plugins/xep_0004/stanza/form.py b/sleekxmpp/plugins/xep_0004/stanza/form.py index cca9d2e0..f55e88a9 100644 --- a/sleekxmpp/plugins/xep_0004/stanza/form.py +++ b/sleekxmpp/plugins/xep_0004/stanza/form.py @@ -22,8 +22,7 @@ class Form(ElementBase): namespace = 'jabber:x:data' name = 'x' plugin_attrib = 'form' - interfaces = set(('instructions', 'items', - 'reported', 'title', 'type', )) + interfaces = set(('instructions', 'items', 'reported', 'title', 'type', )) sub_interfaces = set(('title',)) form_types = set(('cancel', 'form', 'result', 'submit')) @@ -43,7 +42,7 @@ class Form(ElementBase): @property def field(self): - return self['fields'] + return self.get_fields() def set_type(self, ftype): self._set_attr('type', ftype) @@ -178,7 +177,7 @@ class Form(ElementBase): def get_values(self): values = OrderedDict() - fields = self['fields'] + fields = self.get_fields() for var in fields: values[var] = fields[var]['value'] return values @@ -226,7 +225,7 @@ class Form(ElementBase): self.add_reported(var, **field) def set_values(self, values): - fields = self['fields'] + fields = self.get_fields() for field in values: if field not in self.get_fields(): fields[field] = self.add_field(var=field) diff --git a/tests/test_stream_xep_0050.py b/tests/test_stream_xep_0050.py index 261a0057..0a3eb718 100644 --- a/tests/test_stream_xep_0050.py +++ b/tests/test_stream_xep_0050.py @@ -119,7 +119,7 @@ class TestAdHocCommands(SleekTest): def handle_command(iq, session): def handle_form(form, session): - results.append(form['values']['foo']) + results.append(form.get_values()['foo']) form = self.xmpp['xep_0004'].makeForm('form') form.addField(var='foo', ftype='text-single', label='Foo') @@ -191,10 +191,10 @@ class TestAdHocCommands(SleekTest): def handle_command(iq, session): def handle_step2(form, session): - results.append(form['values']['bar']) + results.append(form.get_values()['bar']) def handle_step1(form, session): - results.append(form['values']['foo']) + results.append(form.get_values()['foo']) form = self.xmpp['xep_0004'].makeForm('form') form.addField(var='bar', ftype='text-single', label='Bar') @@ -426,7 +426,7 @@ class TestAdHocCommands(SleekTest): def handle_form(forms, session): for form in forms: - results.append(form['values']['FORM_TYPE']) + results.append(form.get_values()['FORM_TYPE']) form1 = self.xmpp['xep_0004'].makeForm('form') form1.addField(var='FORM_TYPE', ftype='hidden', value='form_1') -- cgit v1.2.3