Fix xep_0050 changes after form refactor.

This commit is contained in:
Robert Robinson 2015-09-14 17:00:53 -06:00
parent 0724f623bb
commit 93c705fb31
2 changed files with 8 additions and 9 deletions

View file

@ -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)

View file

@ -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')