class ISchemaTest(Interface): title = Bytes(title="Title", description="Title", default=b"", required=True) description = Bytes(title="Description", description="Description", default=b"", required=True) spam = Bytes(title="Spam", description="Spam", default=b"", required=True)
def _makeSchema(): from zope.interface import Interface from guillotina.schema import Bytes return InterfaceClass( "ISchemaTest", (Interface,), { "title": Bytes(title="Title", description="Title", default=b"", required=True), "description": Bytes(title="Description", description="Description", default=b"", required=True), "spam": Bytes(title="Spam", description="Spam", default=b"", required=True), }, "", "guillotina.schema.tests.test_schema", )
def test_w_fields(self): from guillotina.schema import Text from guillotina.schema import Bytes from guillotina.schema import Int from guillotina.schema import Float from guillotina.schema import Decimal self.assertEqual(self._callFUT([Text()]), True) self.assertEqual(self._callFUT([Bytes()]), True) self.assertEqual(self._callFUT([Int()]), True) self.assertEqual(self._callFUT([Float()]), True) self.assertEqual(self._callFUT([Decimal()]), True) self.assertEqual( self._callFUT([Text(), Bytes(), Int(), Float(), Decimal()]), True)
def _makeSchema(): from zope.interface import Interface from guillotina.schema import Bytes return InterfaceClass( 'ISchemaTest', (Interface, ), { 'title': Bytes( title="Title", description="Title", default=b"", required=True), 'description': Bytes(title="Description", description="Description", default=b"", required=True), 'spam': Bytes(title="Spam", description="Spam", default=b"", required=True) }, '', 'guillotina.schema.tests.test_schema')
def test_w_normal_fields(self): from guillotina.schema import Text from guillotina.schema import Bytes from guillotina.schema import Int from guillotina.schema import Float from guillotina.schema import Decimal self.assertEqual(self._callFUT(Text()), True) self.assertEqual(self._callFUT(Bytes()), True) self.assertEqual(self._callFUT(Int()), True) self.assertEqual(self._callFUT(Float()), True) self.assertEqual(self._callFUT(Decimal()), True)
def _makeDerivedSchema(base=None): from guillotina.schema import Bytes if base is None: base = _makeSchema() return InterfaceClass( 'ISchemaTestSubclass', (base, ), { 'foo': Bytes(title='Foo', description='Fooness', default=b"", required=False) }, '', 'guillotina.schema.tests.test_schema')
def _makeDerivedSchema(base=None): from guillotina.schema import Bytes if base is None: base = _makeSchema() return InterfaceClass( "ISchemaTestSubclass", (base,), {"foo": Bytes(title="Foo", description="Fooness", default=b"", required=False)}, "", "guillotina.schema.tests.test_schema", )
def test_w_mixed(self): from guillotina.schema import Text from guillotina.schema import Bytes from guillotina.schema import Int from guillotina.schema import Float from guillotina.schema import Decimal self.assertEqual(self._callFUT([Text(), 0]), False) self.assertEqual( self._callFUT([Text(), Bytes(), Int(), Float(), Decimal(), 0]), False)
class ISchemaTestSubclass(base): foo = Bytes( title='Foo', description='Fooness', default=b"", required=False)
class Schema(Interface): title = Text(description="Short summary", default="say something") weight = Float(min=0.0) code = Bytes(min_length=6, max_length=6, default=b"xxxxxx") date = Float(title="Date", readonly=True)