forked from jahinzee/theouchteam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_util.py
67 lines (60 loc) · 1.36 KB
/
test_util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import json
from src.util import Util
# Testing inputs
if __name__ == "__main__":
# Testing Place order
vals = [
b'O',
1234,
b"Claire ", # This must be 10 characters. Fill the unused characters with spaces.
b'B',
345624,
1234,
b"DAY ", # This must be 4 characters.
500000.5, # Price = $500000.5
99999,
5834,
b"P",
b"P",
1234,
b'1',
b'1'
]
b = Util.package(vals)
msg_dict = Util.unpackage(b[0:1], b[1:]) # Separate header byte from rest of the bytes.
print(json.dumps( # Make the dictionary easy to read
msg_dict,
indent = 4,
separators = (',', ': ')
))
# Testing replace order
vals = [
b'U',
1234,
1235,
100000,
5000.5,
0,
b" ",
555
]
b = Util.package(vals)
msg_dict = Util.unpackage(b[0:1], b[1:])
print(json.dumps( # Make the dictionary easy to read
msg_dict,
indent = 4,
separators = (',', ': ')
))
# Testing Cancel Order
vals = [
b'X',
1234,
0
]
b = Util.package(vals)
msg_dict = Util.unpackage(b[0:1], b[1:])
print(json.dumps( # Make the dictionary easy to read
msg_dict,
indent = 4,
separators = (',', ': ')
))