'Check that values get converted into the field type during validation'

def testTypeConversionFeature(self):

    s3db = current.s3db
    resource = s3db.resource('project_organisation')
    request = Storage(prefix='project', name='organisation', resource=resource, table=resource.table, tablename=resource.tablename, method='validate', get_vars=Storage(), representation='json', http='GET')
    crud = resource.crud
    jsonstr = '{"organisation_id":"1",    "role":"1"}'
    request.body = StringIO(jsonstr)
    output = crud.validate(request)
    self.assertTrue(isinstance(output, basestring))
    data = json.loads(output)
    self.assertTrue(isinstance(data, dict))
    self.assertEqual(len(data), 2)
    self.assertTrue(('role' in data))
    role = data['role']
    self.assertTrue(isinstance(role, dict))
    self.assertTrue(('value' in role))
    self.assertTrue(isinstance(role['value'], int))
