Blame view

sockets_tele/test/test_client_gemini.py 1.31 KB
fc6ea9bc   Etienne Pallier   socket client pou...
1
2
3
4
5
6
#!/usr/bin/env python3

import unittest

import sys
sys.path.append('..')
ca2504aa   Etienne Pallier   Nouvelle version ...
7
8
from src.client.socket_client_telescope_gemini import SocketClientTelescopeGEMINI

fc6ea9bc   Etienne Pallier   socket client pou...
9
10
11
12
13
14
15
16
17
18
19
20
21

class TestClient(unittest.TestCase):

    def setUp(self):
        self.seq = range(10)

    def test_run(self):
        
        #HOST, PORT = "localhost", 9999
        #HOST, PORT = "localhost", 20001
        HOST, PORT = "localhost", 11110
        
        qa = [
ca2504aa   Etienne Pallier   Nouvelle version ...
22
23
            (':toto#', 'TOTO'),
            (':GD#', '+12:28')
fc6ea9bc   Etienne Pallier   socket client pou...
24
25
26
27
            #(':GD#', '+12:28')
        ]
        
        #tsock = SocketClient_UDP_TCP(HOST, PORT, "UDP")
ca2504aa   Etienne Pallier   Nouvelle version ...
28
        with SocketClientTelescopeGEMINI(HOST, PORT) as tsock:
fc6ea9bc   Etienne Pallier   socket client pou...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
            # Only useful for TCP (does nothing for UDP)
            tsock._connect_to_server()
            
            # 1) SEND REQUEST data to server
            
            for data in qa:
                question,answer = data
                tsock.send_data(question)
        
                # 2) RECEIVE REPLY data from server
                data_received = tsock.receive_data()
                self.assertEqual(data_received, answer)
            
            radec = tsock.get("RA-DEC")
ca2504aa   Etienne Pallier   Nouvelle version ...
43
44
            print("ra-dec is", radec)
            self.assertEqual(radec,  ['15:01:48', '+12:28'])
fc6ea9bc   Etienne Pallier   socket client pou...
45
46
47
48
49
            
            #tsock.close()

if __name__ == '__main__':
    unittest.main()