-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
97 lines (86 loc) · 1.93 KB
/
test.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from chickenfoot import Chickenfoot
import socket
class TestChickenfootClient():
def setUp(self):
TCP_IP = '192.168.0.6'
TCP_PORT = 5005
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.connect((TCP_IP, TCP_PORT))
def tearDown(self):
self.s.close()
def test_moves(self):
self.left()
self.right()
self.stop_wheel()
self.up()
self.down()
self.stop()
def left(self):
bundle = """
{
"m" : "M1",
"a" : "rl",
"p" : {
"p1name" : "p1",
"p2name": 5
}
}
"""
assert self.__send(bundle)
def right(self):
bundle = """
{
"m" : "M1",
"a" : "rr",
"p" : {
"p1name" : "p1"
}
}
"""
assert self.__send(bundle)
def up(self):
bundle = """
{
"m" : "M2",
"a" : "fw",
"p" : {
"p1name" : "p1",
"p2name" : "p2"
}
}
"""
assert self.__send(bundle)
def down(self):
bundle = """
{
"m" : "M2",
"a" : "rw"
}
"""
assert self.__send(bundle)
def stop(self):
bundle = """
{
"m" : "M1",
"a" : "stop",
"p" : {
"p1name" : "stop"
}
}
"""
assert self.__send(bundle)
def stop_wheel(self):
bundle = """
{
"m" : "M2",
"a" : "stop",
"p" : {
"p1name" : "stop_wheel"
}
}
"""
assert self.__send(bundle)
def __send(self, data):
byte_to_send = len(data) + 1
byte_sent = self.s.send(data + "\n")
return byte_sent == byte_to_send