'Test Export Options (all options, XML)'

def testExportOptionsXML(self):

    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    options = dict(self.records)
    resource = current.s3db.resource('fotest_table')
    result = resource.export_options(fields=['lookup'])
    fo = etree.XML(result)
    xml = current.xml
    ATTRIBUTE = xml.ATTRIBUTE
    VALUE = ATTRIBUTE.value
    UID = xml.UID
    has_empty = False
    self.assertEqual(len(fo), (len(options) + 1))
    for opt in fo:
        assertEqual(opt.tag, 'option')
        attr = opt.attrib
        assertTrue((VALUE in attr))
        value = attr[VALUE]
        if (value == ''):
            has_empty = True
            self.assertFalse((UID in attr))
            assertEqual(opt.text, None)
            continue
        else:
            value = int(value)
        assertTrue((value in options))
        assertEqual(opt.text, options[value]['name'])
    assertTrue(has_empty, msg='Empty-option    missing')
