Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
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",
    )
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
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')
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
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')
Exemplo n.º 7
0
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",
    )
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 class ISchemaTestSubclass(base):
     foo = Bytes(
         title='Foo',
         description='Fooness',
         default=b"",
         required=False)
Exemplo n.º 10
0
 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)