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 
20 import test_objects
21 import importlib
22 importlib.reload(test_objects)
23 from test_objects import *
24 
25 from atlas.codecs import binary1
26 importlib.reload(binary1)
27 from atlas.codecs.binary1 import *
28 
29 from atlas.transport.negotiation import NegotiationClient
30 
31 #import pdb
32 #pdb.set_trace()
33 
34 file_content = open("test.binary1").read()
35 neg = NegotiationClient(["Binary1_beta"])
36 assert(neg(file_content)=="found")
37 if neg.str != gen_binary1(msg)[2:]: #reason for [2:]: drop list encoding from it
38  print("Binary1 encoding not same!")
39 
40 parse = get_parser()
41 msg2 = parse(gen_binary1(msg)[2:])
42 file_content = open("test.binary1").read()
43 neg = NegotiationClient(["Binary1_beta"])
44 assert(neg(file_content)=="found")
45 if neg.str != gen_binary1(msg2)[2:]:
46  print("Binary1 decoding and Binary1 encoding not same!")
47