def testRoundTrip(self): obj = {symbol("key"): timestamp(1234), ulong(123): "blah", char("c"): "bleh", str2unicode("desc"): Described(symbol("url"), str2unicode("http://example.org")), str2unicode("array"): Array(UNDESCRIBED, Data.INT, 1, 2, 3), str2unicode("list"): [1, 2, 3, None, 4], str2unicode("boolean"): True} self.data.put_object(obj) enc = self.data.encode() data = Data() data.decode(enc) data.rewind() assert data.next() copy = data.get_object() assert copy == obj, (copy, obj)
def testLookup(self): obj = {symbol("key"): str2unicode("value"), symbol("pi"): 3.14159, symbol("list"): [1, 2, 3, 4]} self.data.put_object(obj) self.data.rewind() self.data.next() self.data.enter() self.data.narrow() assert self.data.lookup("pi") assert self.data.get_object() == 3.14159 self.data.rewind() assert self.data.lookup("key") assert self.data.get_object() == str2unicode("value") self.data.rewind() assert self.data.lookup("list") assert self.data.get_object() == [1, 2, 3, 4] self.data.widen() self.data.rewind() assert not self.data.lookup("pi")