Exemple #1
0
 class Dummy(mapping.Mapping):
     foo = mapping.Field(default='bar')
     bar = mapping.ComponentField(mapping=mapping.Component.build(
         mapping.IntegerField(name='a'),
         mapping.IntegerField(name='b'),
         mapping.IntegerField(name='c'),
     ),
                                  default=[1, 2, 3])
Exemple #2
0
 class Dummy(mapping.Mapping):
     field = mapping.Field(length=10)
Exemple #3
0
 class Dummy(mapping.Mapping):
     field = mapping.Field(required=True)
Exemple #4
0
 class Dummy(mapping.Mapping):
     field = mapping.ComponentField(mapping=mapping.Component.build(
         mapping.Field(name='foo'), mapping.IntegerField(name='bar'),
         mapping.ConstantField(name='baz', default='42')))
Exemple #5
0
 class Dummy(mapping.Mapping):
     field = mapping.Field(default=lambda: 'foobar')
Exemple #6
0
 def test_init_with_custom_default_value(self):
     f = mapping.Field(default='foo')
     self.assertEqual(f.default, 'foo')
Exemple #7
0
 def test_init_with_custom_name(self):
     f = mapping.Field(name='foo')
     self.assertEqual(f.name, 'foo')
Exemple #8
0
 def test_init_default(self):
     f = mapping.Field()
     self.assertTrue(hasattr(f, 'name'))
     self.assertTrue(hasattr(f, 'default'))
     self.assertEqual(f.name, None)
     self.assertEqual(f.default, None)