'Test export options, JSON, all options'

def testExportOptionsAllOptsJSON(self):

    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    options = dict(self.records)
    resource = current.s3db.resource('fotest_table')
    result = resource.export_options(fields=['lookup'], as_json=True)
    fo = json.loads(result)
    has_empty = False
    assertTrue(isinstance(fo, dict))
    assertTrue(('option' in fo))
    assertTrue(isinstance(fo['option'], list))
    assertEqual(len(fo['option']), (len(options) + 1))
    for opt in fo['option']:
        value = opt['@value']
        if (value == ''):
            has_empty = True
            self.assertFalse(('$' in opt))
            continue
        else:
            value = int(value)
        assertTrue((value in options))
        assertEqual(opt['$'], options[value]['name'])
    assertTrue(has_empty, msg='Empty-option    missing')
