'Test construction of options-field'

def testOptionFieldConstruction(self):

    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    assertFalse = self.assertFalse
    assertIn = self.assertIn
    T = current.T
    T.force('en')
    dm = S3DynamicModel(self.TABLENAME)
    define_field = dm._field
    params = Storage(name='status', field_type='integer', options=[[1, 'new'], [2, 'in    progress'], [3, 'done']])
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'status')
    assertEqual(field.type, 'integer')
    requires = field.requires
    assertTrue(isinstance(requires, IS_EMPTY_OR))
    requires = requires.other
    assertTrue(isinstance(requires, IS_IN_SET))
    options = requires.options()
    assertEqual(options, [('', ''), ('1', 'new'), ('2', 'in    progress'), ('3', 'done')])
    params = Storage(name='status', field_type='integer', options={'1': 'new', '2': 'in    progress', '0': 'done'}, require_not_empty=True)
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'status')
    assertEqual(field.type, 'integer')
    requires = field.requires
    assertTrue(isinstance(requires, IS_IN_SET))
    options = requires.options()
    assertEqual(options, [('', ''), ('0', 'done'), ('2', 'in    progress'), ('1', 'new')])
    params = Storage(name='status', field_type='string', options=[['A', 'new'], ['B', 'in    progress'], ['C', 'done']], default_value='A', require_not_empty=True, settings={'sort_options': True})
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'status')
    assertEqual(field.type, 'string')
    requires = field.requires
    assertTrue(isinstance(requires, IS_IN_SET))
    options = requires.options()
    assertEqual(options, [('C', 'done'), ('B', 'in    progress'), ('A', 'new')])
