-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_satellite.py
More file actions
31 lines (27 loc) · 875 Bytes
/
test_satellite.py
File metadata and controls
31 lines (27 loc) · 875 Bytes
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
# Test for Satellite class
import unittest
from satellite import Satellite
import numpy as np
class TestSatellite(unittest.TestCase):
def test_init(self):
"""
Test basic initialization of satellite
"""
r = np.array([1.0, 2.5, 3])
v = np.array([0, 0, 1.0])
m = 1000
s = Satellite(position=r, velocity=v, mass=m)
print(str(s))
self.assertTrue(all(s.position == r))
self.assertTrue(all(s.velocity == v))
self.assertEqual(s.mass, m)
def test_uuid(self):
"""
Create 10000 satellites and make sure their UUIDs are all unique
"""
sats = [Satellite() for x in range(10000)]
sat_ids = [s.id for s in sats]
sat_id_set = set(sat_ids)
self.assertTrue(len(sat_ids) == len(sat_id_set))
if __name__ == '__main__':
unittest.main()