-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_integration.py
42 lines (29 loc) · 1 KB
/
test_integration.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
import client, server
import cv2
from multiprocessing import Process, Manager
def view_ball():
ball = server.BouncingBall(500, 500, 20, server.BouncingBall.BallSpeed.SLOW)
while True:
updated_ball = ball.increment_ball()
cv2.startWindowThread()
cv2.imshow('screensaver', updated_ball)
key = cv2.waitKey(1)
if key == '27': # escape
break
def test_finding_circle_error_after_one_slow_increment():
queue_a = Manager().Queue()
queue_b = Manager().Queue()
queue_c = Manager().Queue()
ball = server.BouncingBall(500, 500, 20, server.BouncingBall.BallSpeed.SLOW)
new_ball_img = ball.increment_ball()
queue_a.put(new_ball_img)
p1 = Process(target=client.process_a, args=(queue_a, queue_b,))
p1.start()
p2 = Process(target=server.calculate_error, args=(ball, queue_b, queue_c,))
p2.start()
p1.join()
p2.join()
dist_error = queue_c.get()
assert dist_error < 10.0
if __name__ == '__main__':
view_ball()