class OperationSetBinData(Operation): object_type = 'set_bindata' key = fields.String() start = fields.SmallUnsignedInteger(default=0) data = fields.Binary() truncate = fields.Boolean(default=False)
class CheckBinData(Check): object_type = 'bindata' node = fields.NodeID() key = fields.String() start = fields.SmallUnsignedInteger() end = fields.SmallUnsignedInteger(optional=True) data = fields.Binary()
class MsgGetBinDataReply(MsgpackMsg): """ Sent by server in reply to MsgGetBinData. """ object_type = 'get_bindata_reply' qid = fields.SmallUnsignedInteger() data = fields.Binary()
class OperationCreate(Operation): object_type = 'create' parent = fields.NodeID(default=NodeID.root_id) pos_start = fields.Integer(optional=True) pos_end = fields.Integer(optional=True) tags = fields.Set(fields.String()) attr = fields.Map(fields.String(), fields.Any()) data = fields.Map(fields.String(), fields.Any()) bindata = fields.Map(fields.String(), fields.Binary()) triggers = fields.Set(fields.String())
def test_binary(self): a = fields.Binary() a.validate(b'abcd') with self.assertRaises(SchemaError): a.validate('abcd') with self.assertRaises(SchemaError): a.validate(1234) self.assertEqual(a.dump(b'abcd'), b'abcd') self.assertEqual(a.load(b'abcd'), b'abcd') with self.assertRaises(SchemaError): a.load('abcd') with self.assertRaises(SchemaError): a.load(1234)
class MsgSetBinData(MsgpackMsg): """ Sets a range of bindata on a given node. Server replies with MsgRequestAck or MsgRequestError. The bindata is modified starting from a given start position - it is an error if the position is after the current end of bindata (but not if it's equal). The bindata is expanded if necessary to hold the new data. If truncate is set, the bindata is truncated after the end of the new data. If bindata would become 0-length, it is deleted. """ object_type = 'set_bindata' rid = fields.SmallUnsignedInteger() id = fields.NodeID() key = fields.String() start = fields.SmallUnsignedInteger(default=0) data = fields.Binary() truncate = fields.Boolean(default=False)
class MsgCreate(MsgpackMsg): """ Creates a node on the server. It is an error if a node with given id already exists. Server replies with MsgRequestAck or MsgRequestError. Replies are matched to requests by ``rid``, which is assigned by the client. """ object_type = 'create' rid = fields.SmallUnsignedInteger() id = fields.NodeID() parent = fields.NodeID(default=NodeID.root_id) pos_start = fields.Integer(optional=True) pos_end = fields.Integer(optional=True) tags = fields.Set(fields.String()) attr = fields.Map(fields.String(), fields.Any()) data = fields.Map(fields.String(), fields.Any()) bindata = fields.Map(fields.String(), fields.Binary()) triggers = fields.Set(fields.String())
class BinaryOptional(model.Model): a = fields.Binary(optional=True)
class Binary(model.Model): a = fields.Binary()
class SubType2(BaseModel): object_type = 'sub2' b = fields.Binary()
class TurboZlew(Zlew): object_type = 'turbozlew' dopalacz = fields.Binary()
class TurboZlew(Zlew): c = fields.Set(fields.Binary()) d = fields.Object(Piwo) e = fields.Integer(default=3)