Esempio n. 1
0
 def __init__(self, name, mode="r", codec_id=None):
     self.name = name
     self.fp = open(name, mode)
     self.mode = mode
     self.objects = atlas.Messages()
     if mode=="r":
         self.bridge = Bridge(NegotiationClient(), functions=self)
     else:
         if codec_id:
             self.codec_id = codec_id
         else:
             self.codec_id = codecs.get_default_codec().id
         self.bridge = Bridge(NegotiationServer(codecs=(self.codec_id,)), functions=self)
         self.other_negotiation = NegotiationClient()
Esempio n. 2
0
                    assert (
                        not res_lst
                    )  #if 2 test messages are some day codec inside 5 bytes: will fail falsely
                    lst.append(obj)
            assert (str(lst) == res)

        test_stream_decode(s1, res1)
        test_stream_decode(s2, res2)
        test_stream_decode(s3, res3)

        ############################################################
        # test from file
        co.set_stream_mode()
        file_name = "test." + file_extension
        file_content = open(file_name).read()
        neg1 = NegotiationClient([codec_id])
        assert (neg1(file_content) == "found")
        str1 = co.encode(msg) + co.encoder.close()
        if neg1.str != str1:
            print(codec_id + " encoding not same!")

        msg2 = co.decode(str1)
        file_content = open(file_name).read()
        neg2 = NegotiationClient([codec_id])
        assert (neg2(file_content) == "found")
        str2 = co.encode(msg2) + co.encoder.close()
        if neg2.str != str2:
            print("%(codec_id)s decoding and %(codec_id)s encoding not same!" %
                  locals())

        assert (co.decoder.eos())
Esempio n. 3
0
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import test_objects
reload(test_objects)
from test_objects import *

from atlas.codecs import binary1
reload(binary1)
from atlas.codecs.binary1 import *

from atlas.transport.negotiation import NegotiationClient

#import pdb
#pdb.set_trace()

file_content = open("test.binary1").read()
neg = NegotiationClient(["Binary1_beta"])
assert (neg(file_content) == "found")
if neg.str != gen_binary1(
        msg)[2:]:  #reason for [2:]: drop list encoding from it
    print "Binary1 encoding not same!"

parse = get_parser()
msg2 = parse(gen_binary1(msg)[2:])
file_content = open("test.binary1").read()
neg = NegotiationClient(["Binary1_beta"])
assert (neg(file_content) == "found")
if neg.str != gen_binary1(msg2)[2:]:
    print "Binary1 decoding and Binary1 encoding not same!"
Esempio n. 4
0
 def __init__(self):
     Common.__init__(self)
     self.bridge = Bridge(NegotiationClient(), functions=self)