class MsgConnected(MsgpackMsg): """ Sent by the server in reply to MsgConnect. """ object_type = 'connected' proto_version = fields.SmallInteger(minimum=1) server_name = fields.String() server_version = fields.String()
class MsgConnect(MsgpackMsg): """ Sent by the client immediately upon connection. Server replies with MsgConnected or MsgConnectionError. """ object_type = 'connect' proto_version = fields.SmallInteger(minimum=1) client_name = fields.String(optional=True) client_version = fields.String(optional=True) client_description = fields.String(optional=True) client_type = fields.String(optional=True) quit_on_close = fields.Boolean(default=False)
def test_small_integer(self): a = fields.SmallInteger() a.validate(0) a.validate(-1) a.validate(1) a.validate(-0x8000000000000000) a.validate(0x7fffffffffffffff) with self.assertRaises(SchemaError): a.validate(-0x8000000000000001) with self.assertRaises(SchemaError): a.validate(0x8000000000000000) fields.SmallInteger(minimum=-1) fields.SmallInteger(maximum=-1) fields.SmallInteger(maximum=0x7fffffffffffffff) fields.SmallInteger(minimum=-0x8000000000000000) with self.assertRaises(ValueError): fields.SmallInteger(maximum=0x8000000000000000) with self.assertRaises(ValueError): fields.SmallInteger(minimum=-0x8000000000000001) with self.assertRaises(TypeError): fields.SmallInteger(maximum=None) with self.assertRaises(TypeError): fields.SmallInteger(minimum=None)
class List(model.Model): a = fields.List(fields.SmallInteger())
class SmallInteger(model.Model): a = fields.SmallInteger(default=-42)
class SmallIntegerOptional(model.Model): a = fields.SmallInteger(optional=True)
class MapOptional(model.Model): a = fields.Map(fields.String(), fields.SmallInteger(), optional=True, default=None)
class Map(model.Model): a = fields.Map(fields.String(), fields.SmallInteger())
class SetOptional(model.Model): a = fields.Set(fields.SmallInteger(), optional=True, default=None)
class Set(model.Model): a = fields.Set(fields.SmallInteger())
class FieldTypeFixed(FieldType): shift = fields.SmallInteger() sign_mode = fields.Enum(FieldSignMode)