Exemple #1
0
 def testXid(self):
   sc = StringCodec()
   xid = Xid(format=0, global_id="gid", branch_id="bid")
   sc.write_compound(xid)
   assert sc.encoded == '\x00\x00\x00\x10\x06\x04\x07\x00\x00\x00\x00\x00\x03gid\x03bid'
   dec = sc.read_compound(Xid)
   assert xid.__dict__ == dec.__dict__
Exemple #2
0
 def check(self, type, value, compare=True):
   t = PRIMITIVE[type]
   sc = StringCodec()
   sc.write_primitive(t, value)
   decoded = sc.read_primitive(t)
   if compare:
     assert decoded == value, "%s, %s" % (decoded, value)
   return decoded
 def check(self, type, value, compare=True):
     t = PRIMITIVE[type]
     sc = StringCodec()
     sc.write_primitive(t, value)
     decoded = sc.read_primitive(t)
     if compare:
         assert decoded == value, "%s, %s" % (decoded, value)
     return decoded
Exemple #4
0
  def testSessionHeader(self):
    sc = StringCodec()
    sc.write_compound(Header(sync=True))
    assert sc.encoded == "\x01\x01"

    sc = StringCodec()
    sc.write_compound(Header(sync=False))
    assert sc.encoded == "\x01\x00"
Exemple #5
0
 def encdec(self, value):
   sc = StringCodec()
   sc.write_compound(value)
   decoded = sc.read_compound(value.__class__)
   return decoded
Exemple #6
0
 def decode(x):
   sc = StringCodec(x)
   return sc.read_primitive(type)
Exemple #7
0
 def encode(x):
   sc = StringCodec()
   sc.write_primitive(type, x)
   return sc.encoded