Ejemplo n.º 1
0
 def test_list(self):
     a = fields.List(fields.Object(Piwo))
     a.validate([])
     a.validate([Piwo()])
     a.validate([Piwo(), Piwo(), Piwo()])
     with self.assertRaises(SchemaError):
         a.validate(Piwo())
     with self.assertRaises(SchemaError):
         a.validate(set())
     with self.assertRaises(SchemaError):
         a.validate(None)
     with self.assertRaises(SchemaError):
         a.validate([Piwo(), Zlew(), Piwo()])
     with self.assertRaises(SchemaError):
         a.validate([Piwo(), None])
     self.assertEqual(a.load([]), [])
     self.assertEqual(a.load(['piwo', 'piwo']), [Piwo(), Piwo()])
     with self.assertRaises(SchemaError):
         a.validate(a.load({}))
     with self.assertRaises(SchemaError):
         a.validate(a.load(None))
     with self.assertRaises(SchemaError):
         a.validate(a.load('piwo'))
     with self.assertRaises(SchemaError):
         a.validate(a.load(['zlew']))
     with self.assertRaises(SchemaError):
         a.validate(a.load(['piwo', None]))
     self.assertEqual(a.dump([]), [])
     self.assertEqual(a.dump([Piwo(), Piwo()]), ['piwo', 'piwo'])
     fields.List(fields.Integer(), default=[1, 2, 3])
Ejemplo n.º 2
0
class MsgGetListReply(MsgpackMsg):
    """
    Sent by server in reply to MsgGetList.
    """

    object_type = 'get_list_reply'

    qid = fields.SmallUnsignedInteger()
    objs = fields.List(fields.Object(Node))
    gone = fields.List(fields.NodeID())
Ejemplo n.º 3
0
class MsgTransaction(MsgpackMsg):
    """
    Sent by the client to request a list of database-modifying operations.
    The operations are executed atomically, and only if the attached checks
    are still valid.
    """

    object_type = 'transaction'

    rid = fields.SmallUnsignedInteger()
    checks = fields.List(fields.Object(Check))
    operations = fields.List(fields.Object(Operation))
Ejemplo n.º 4
0
class MsgPluginTriggerDone(MsgpackMsg):
    """
    Sent by the client in reply to MsgPluginTriggerRun.
    """

    object_type = 'plugin_trigger_done'

    ptid = fields.SmallUnsignedInteger()
    checks = fields.List(fields.Object(Check))
Ejemplo n.º 5
0
class MsgPluginBroadcastResult(MsgpackMsg):
    """
    Sent by the client in reply to MsgPluginBroadcastRun.
    """

    object_type = 'plugin_broadcast_result'

    pbid = fields.SmallUnsignedInteger()
    results = fields.List(fields.Any(optional=True))
Ejemplo n.º 6
0
class MsgBroadcastResult(MsgpackMsg):
    """
    Sent by the server in reply to MsgBroadcastRun.
    """

    object_type = 'broadcast_result'

    bid = fields.SmallUnsignedInteger()
    results = fields.List(fields.Any(optional=True))
Ejemplo n.º 7
0
class MsgPluginTriggerError(MsgpackMsg):
    """
    Sent by the client in reply to MsgPluginTriggerRun.
    """

    object_type = 'plugin_trigger_error'

    ptid = fields.SmallUnsignedInteger()
    err = fields.Object(VelesException)
    checks = fields.List(fields.Object(Check))
Ejemplo n.º 8
0
class MsgPluginQueryError(MsgpackMsg):
    """
    Sent by the client in reply to MsgPluginQueryGet.
    """

    object_type = 'plugin_query_error'

    pqid = fields.SmallUnsignedInteger()
    err = fields.Object(VelesException)
    checks = fields.List(fields.Object(Check))
Ejemplo n.º 9
0
class MsgPluginQueryResult(MsgpackMsg):
    """
    Sent by the client in reply to MsgPluginQueryGet.
    """

    object_type = 'plugin_query_result'

    pqid = fields.SmallUnsignedInteger()
    result = fields.Any(optional=True)
    checks = fields.List(fields.Object(Check))
Ejemplo n.º 10
0
class MsgQueryError(MsgpackMsg):
    """
    Sent by the server in reply to MsgGet*.  Note that receiving this doesn't
    kill the subscription - a successful reply may be sent later if
    the situation improves.
    """

    object_type = 'query_error'

    qid = fields.SmallUnsignedInteger()
    err = fields.Object(VelesException)
    checks = fields.List(fields.Object(Check))
Ejemplo n.º 11
0
class MsgConnectionsReply(MsgpackMsg):
    object_type = 'connections_reply'

    qid = fields.SmallUnsignedInteger()
    connections = fields.List(fields.Object(Connection))
Ejemplo n.º 12
0
class MsgGetQueryReply(MsgpackMsg):
    object_type = 'get_query_reply'

    qid = fields.SmallUnsignedInteger()
    result = fields.Any(optional=True)
    checks = fields.List(fields.Object(Check))
Ejemplo n.º 13
0
class List(model.Model):
    a = fields.List(fields.SmallInteger())
Ejemplo n.º 14
0
class ListOptional(model.Model):
    a = fields.List(fields.SmallInteger(), optional=True, default=None)
Ejemplo n.º 15
0
class PietroZlew(WieloZlew):
    object_type = 'pietrozlew'
    pietra = fields.List(fields.Object(BaseZlew))
Ejemplo n.º 16
0
class Zlew(Model):
    b = fields.List(fields.Map(fields.String(), fields.BinData()))