Atlas 0.7.0
Networking protocol for the Worldforge system.
test_binary.py
1#test binary1 codec
2
3#Copyright 2000, 2001 by Aloril
4
5#This library is free software; you can redistribute it and/or
6#modify it under the terms of the GNU Lesser General Public
7#License as published by the Free Software Foundation; either
8#version 2.1 of the License, or (at your option) any later version.
9
10#This library is distributed in the hope that it will be useful,
11#but WITHOUT ANY WARRANTY; without even the implied warranty of
12#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13#Lesser General Public License for more details.
14
15#You should have received a copy of the GNU Lesser General Public
16#License along with this library; if not, write to the Free Software
17#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20import test_objects
21import importlib
22importlib.reload(test_objects)
23from test_objects import *
24
25from atlas.codecs import binary1
26importlib.reload(binary1)
27from atlas.codecs.binary1 import *
28
29from atlas.transport.negotiation import NegotiationClient
30
31#import pdb
32#pdb.set_trace()
33
34file_content = open("test.binary1").read()
35neg = NegotiationClient(["Binary1_beta"])
36assert(neg(file_content)=="found")
37if neg.str != gen_binary1(msg)[2:]: #reason for [2:]: drop list encoding from it
38 print("Binary1 encoding not same!")
39
40parse = get_parser()
41msg2 = parse(gen_binary1(msg)[2:])
42file_content = open("test.binary1").read()
43neg = NegotiationClient(["Binary1_beta"])
44assert(neg(file_content)=="found")
45if neg.str != gen_binary1(msg2)[2:]:
46 print("Binary1 decoding and Binary1 encoding not same!")
47