'Testing adding fields to a data form.'

def testAddField(self):

    msg = self.Message()
    form = msg['form']
    form.addField(var='f1', ftype='text-single', label='Text', desc='A    text    field', required=True, value='Some    text!')
    self.check(msg, '\n                                        <message>\n                                                <x    xmlns="jabber:x:data"    type="form">\n                                                        <field    var="f1"    type="text-single"    label="Text">\n                                                                <desc>A    text    field</desc>\n                                                                <required    />\n                                                                <value>Some    text!</value>\n                                                        </field>\n                                                </x>\n                                        </message>\n                                ')
    fields = OrderedDict()
    fields['f1'] = {'type': 'text-single', 'label': 'Username', 'required': True}
    fields['f2'] = {'type': 'text-private', 'label': 'Password', 'required': True}
    fields['f3'] = {'type': 'text-multi', 'label': 'Message', 'value': 'Enter    message.\nA    long    one    even.'}
    fields['f4'] = {'type': 'list-single', 'label': 'Message    Type', 'options': [{'label': 'Cool!', 'value': 'cool'}, {'label': 'Urgh!', 'value': 'urgh'}]}
    form.set_fields(fields)
    self.check(msg, '\n                                        <message>\n                                                <x    xmlns="jabber:x:data"    type="form">\n                                                        <field    var="f1"    type="text-single"    label="Username">\n                                                                <required    />\n                                                        </field>\n                                                        <field    var="f2"    type="text-private"    label="Password">\n                                                                <required    />\n                                                        </field>\n                                                        <field    var="f3"    type="text-multi"    label="Message">\n                                                                <value>Enter    message.</value>\n                                                                <value>A    long    one    even.</value>\n                                                        </field>\n                                                        <field    var="f4"    type="list-single"    label="Message    Type">\n                                                                <option    label="Cool!">\n                                                                        <value>cool</value>\n                                                                </option>\n                                                                <option    label="Urgh!">\n                                                                        <value>urgh</value>\n                                                                </option>\n                                                        </field>\n                                                </x>\n                                        </message>\n                                ')
