def test_makeField(self):
        fieldDefs = {
                "pubsub#persist_items":
                    {"type": "boolean",
                     "label": "Persist items to storage"},
                "pubsub#deliver_payloads":
                    {"type": "boolean",
                     "label": "Deliver payloads with event notifications"},
                "pubsub#creator":
                    {"type": "jid-single",
                     "label": "The JID of the node creator"},
                "pubsub#description":
                    {"type": "text-single",
                     "label": "A description of the node"},
                "pubsub#owner":
                    {"type": "jid-single",
                     "label": "Owner of the node"},
                }
        values = {'pubsub#deliver_payloads': '0',
                  'pubsub#persist_items': True,
                  'pubsub#description': 'a great node',
                  'pubsub#owner': jid.JID('user@example.org'),
                  'x-myfield': ['a', 'b']}

        form = data_form.Form('submit')
        form.makeFields(values, fieldDefs)

        # Check that the expected fields have been created
        self.assertIn('pubsub#deliver_payloads', form.fields)
        self.assertIn('pubsub#persist_items', form.fields)
        self.assertIn('pubsub#description', form.fields)
        self.assertIn('pubsub#owner', form.fields)

        # This field is not created because there is no value for it.
        self.assertNotIn('pubsub#creator', form.fields)

        # This field is not created because it does not appear in fieldDefs
        # and filterUnknown defaults to True
        self.assertNotIn('x-myfield', form.fields)

        # Check properties the created fields
        self.assertEqual('boolean',
                         form.fields['pubsub#deliver_payloads'].fieldType)
        self.assertEqual('0',
                         form.fields['pubsub#deliver_payloads'].value)
        self.assertEqual('Deliver payloads with event notifications',
                         form.fields['pubsub#deliver_payloads'].label)
        self.assertEqual(True,
                         form.fields['pubsub#persist_items'].value)
Fields can be created from a dict of values and a dict of field defs.
dataset/ETHPy150Open ralphm/wokkel/wokkel/test/test_data_form.py/FormTest.test_makeField