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])
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())
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))
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))
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))
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))
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))
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))
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))
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))
class MsgConnectionsReply(MsgpackMsg): object_type = 'connections_reply' qid = fields.SmallUnsignedInteger() connections = fields.List(fields.Object(Connection))
class MsgGetQueryReply(MsgpackMsg): object_type = 'get_query_reply' qid = fields.SmallUnsignedInteger() result = fields.Any(optional=True) checks = fields.List(fields.Object(Check))
class List(model.Model): a = fields.List(fields.SmallInteger())
class ListOptional(model.Model): a = fields.List(fields.SmallInteger(), optional=True, default=None)
class PietroZlew(WieloZlew): object_type = 'pietrozlew' pietra = fields.List(fields.Object(BaseZlew))
class Zlew(Model): b = fields.List(fields.Map(fields.String(), fields.BinData()))