-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_test.py
48 lines (39 loc) · 1.49 KB
/
client_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
import unittest, client, communication_channel, protocol, server
class TestClient(unittest.TestCase):
def setUp(self):
factory = communication_channel.CommunicationFactory()
self.server_channel = factory.build_for("server")
self.client_channel = factory.build_for("client")
self.client = client.Client(self.client_channel)
self.server = server.Server(self.server_channel)
def test_initialization(self):
self.assertEqual(self.client_channel, self.client.communication_channel)
self.assertEqual(self.server_channel, self.server.communication_channel)
def root_test(self):
message = self.client._get_root()
test_message = protocol.ClientMessage()
test_message.get_root()
self.assertEqual(message, test_message)
def right_test(self):
message = self.client._move_right(10)
test_message = protocol.ClientMessage()
test_message._move_right(10)
self.assertEqual(message, test_message)
def left_test(self):
message = self.client._move_left(10)
test_message = protocol.ClientMessage()
test_message.move_left(10)
self.assertEqual(message, test_message)
def insert_test(self):
message = self.client._insert(1, 10, 'left')
test_message = protocol.ClientMessage()
test_message.insert(1, 10, 'left')
self.assertEqual(message, test_message)
# TODO test failing
# def test_query(self):
# self.server.run()
# client_message = 010101
# server_response = self.client.query(client_message)
# self.assertEqual(None, server_response)
if __name__ == '__main__':
unittest.main()