Ejemplo n.º 1
0
    def test_get_attribute_values_validation_error(self):
        record = {'test': u'www.example.com'}
        attrmap = {'test': schema.URI(__name__='test')}

        try:
            get_attribute_values(self.request, record, attrmap)
        except ContentImportError, e:
            self.assertEqual(e.colname, 'test')
            self.assertEqual(e.message, u'The specified URI is not valid.')
Ejemplo n.º 2
0
    def test_get_attribute_values(self):
        casts = [
            (schema.Text, u'Test', u'Test'),
            (schema.Int, u'1', 1),
            (schema.Bool, u'True', True),
            (schema.Bool, u'False', False),
            (schema.Bool, u'True', True),
            (schema.Bool, u'', False)
        ]
        for ix, (fieldtype, value, expected) in enumerate(casts):
            key = str(ix)

            record = {key: value}
            attrmap = {key: fieldtype(__name__=key)}

            result = get_attribute_values(self.request, record, attrmap)
            self.assertEqual(result[key], expected)