'Test construction of integer field'

def testIntegerFieldConstruction(self):

    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    assertFalse = self.assertFalse
    dm = S3DynamicModel(self.TABLENAME)
    define_field = dm._field
    params = Storage(name='number', field_type='integer')
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'number')
    assertEqual(field.type, 'integer')
    requires = field.requires
    assertTrue(isinstance(requires, IS_EMPTY_OR))
    requires = requires.other
    assertTrue(isinstance(requires, IS_INT_IN_RANGE))
    params = Storage(name='number', field_type='integer', require_not_empty=True)
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'number')
    assertEqual(field.type, 'integer')
    requires = field.requires
    assertTrue(isinstance(requires, IS_INT_IN_RANGE))
    assertEqual(requires.minimum, None)
    assertEqual(requires.maximum, None)
    params = Storage(name='number', field_type='integer', settings={'min': 2, 'max': 5})
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'number')
    assertEqual(field.type, 'integer')
    requires = field.requires
    assertTrue(isinstance(requires, IS_EMPTY_OR))
    requires = requires.other
    assertTrue(isinstance(requires, IS_INT_IN_RANGE))
    assertEqual(requires.minimum, 2)
    assertEqual(requires.maximum, 5)
    params = Storage(name='number', field_type='integer', default_value='14')
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'number')
    assertEqual(field.type, 'integer')
    assertEqual(field.default, 14)
    params = Storage(name='number', field_type='integer', default_value='not_an_integer')
    field = define_field(self.TABLENAME, params)
    assertEqual(field.name, 'number')
    assertEqual(field.type, 'integer')
    assertEqual(field.default, None)
