-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgroundstation_test.py
More file actions
executable file
·57 lines (49 loc) · 1.87 KB
/
groundstation_test.py
File metadata and controls
executable file
·57 lines (49 loc) · 1.87 KB
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
import unittest
import sys
import os
from groundstation.tests.base import BaseTestCase
sys.path.append(os.path.join(sys.path[0], 'ex2_ground_station_software', 'src'))
from groundStation import GroundStation
"""These tests must be run manually by
`python3 manage.py test groundstation_test`
after running `source ./update.sh` and building libcsp in this repo.
"""
# List of commands to test ground_station_software's DUMMY responses
# FORMAT:
# (command, expected server, expected port, expected buffer)
commands = [
("ex2.time_management.get_time()", 1, 8, b'\n'),
("ari.time_management.set_time(1234567890)", 3, 8, b'\x0bI\x96\x02\xd2'),
("yuk.logger.get_file()", 2, 13, b'\x00'),
("eps.time_management.get_eps_time()", 4, 8, b'\x00'),
("eps.control.single_output_control(10,0,0)", 4, 14, b'\x00\n\x00\x00\x00'),
("eps.configuration.get_active_config(136,2)", 4, 9, b'\x00\x88\x00\x02'),
]
class Options():
"""Dummy container to store ground station options.
"""
pass
class TestGroundstation(BaseTestCase):
@classmethod
def setUpClass(cls):
opts = Options()
opts.interface = 'dummy'
opts.timeout = 10000
opts.hkeyfile = 'test_key.dat'
opts.u = False
opts.device = ''
opts.satellite = 'EX2'
cls.gs = GroundStation(opts)
def test_gs_commands(self):
for c in commands:
with self.subTest(c=c):
transactObj = self.gs.interactive.getTransactionObject(c[0], self.gs.networkManager)
resp = transactObj.execute()
with self.subTest():
self.assertEqual(resp['dst'], c[1])
with self.subTest():
self.assertEqual(resp['dport'], c[2])
with self.subTest():
self.assertEqual(resp['args'], c[3])
if __name__ == '__main__':
unittest.main()