Ignore:
Timestamp:
Apr 22, 2009, 4:53:43 PM (13 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@168
Message:

Don't do type interpretation on parsing Data Forms fields.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_data_form.py

    r51 r56  
    230230
    231231
    232     def test_fromElementValue(self):
    233         element = domish.Element((NS_X_DATA, 'field'))
    234         element.addElement("value", content="text")
     232    def test_fromElementValueTextSingle(self):
     233        """
     234        Parsed text-single field values should be of type C{unicode}.
     235        """
     236        element = domish.Element((NS_X_DATA, 'field'))
     237        element['type'] = 'text-single'
     238        element.addElement('value', content=u'text')
    235239        field = data_form.Field.fromElement(element)
    236240        self.assertEquals('text', field.value)
     241
     242
     243    def test_fromElementValueJID(self):
     244        """
     245        Parsed jid-single field values should be of type C{unicode}.
     246        """
     247        element = domish.Element((NS_X_DATA, 'field'))
     248        element['type'] = 'jid-single'
     249        element.addElement('value', content=u'user@example.org')
     250        field = data_form.Field.fromElement(element)
     251        self.assertEquals(u'user@example.org', field.value)
     252
     253    def test_fromElementValueJIDMalformed(self):
     254        """
     255        Parsed jid-single field values should be of type C{unicode}.
     256
     257        No validation should be done at this point, so invalid JIDs should
     258        also be passed as-is.
     259        """
     260        element = domish.Element((NS_X_DATA, 'field'))
     261        element['type'] = 'jid-single'
     262        element.addElement('value', content=u'@@')
     263        field = data_form.Field.fromElement(element)
     264        self.assertEquals(u'@@', field.value)
     265
     266
     267    def test_fromElementValueBoolean(self):
     268        """
     269        Parsed boolean field values should be of type C{unicode}.
     270        """
     271        element = domish.Element((NS_X_DATA, 'field'))
     272        element['type'] = 'boolean'
     273        element.addElement('value', content=u'false')
     274        field = data_form.Field.fromElement(element)
     275        self.assertEquals(u'false', field.value)
    237276
    238277
Note: See TracChangeset for help on using the changeset viewer.