-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_server.py
67 lines (50 loc) · 2.42 KB
/
test_server.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import server
def test_bouncing_ball_fake_speed():
try:
ball = server.BouncingBall(500, 500, 20, 1)
raise Exception("BouncingBall should have raised ValueError because 1 is not a BallSpeed")
except ValueError:
pass # expected error
def test_bouncing_ball_small_radius_error():
try:
ball = server.BouncingBall(500, 500, 1, server.BouncingBall.BallSpeed.SLOW)
raise Exception("BouncingBall should have raised ValueError because 1 is too small a ball radius")
except ValueError:
pass # expected error
def test_bouncing_ball_large_radius_error():
try:
ball = server.BouncingBall(500, 500, 101, server.BouncingBall.BallSpeed.SLOW)
raise Exception("BouncingBall should have raised ValueError because 101 is too large a ball radius")
except ValueError:
pass # expected error
def test_bouncing_ball_small_length_error():
try:
ball = server.BouncingBall(100, 500, 20, server.BouncingBall.BallSpeed.SLOW)
raise Exception("BouncingBall should have raised ValueError because 100 is too small a window length")
except ValueError:
pass # expected error
def test_bouncing_ball_large_length_error():
try:
ball = server.BouncingBall(3000, 500, 20, server.BouncingBall.BallSpeed.SLOW)
raise Exception("BouncingBall should have raised ValueError because 3000 is too large a window length")
except ValueError:
pass # expected error
def test_bouncing_ball_small_width_error():
try:
ball = server.BouncingBall(500, 200, 20, server.BouncingBall.BallSpeed.SLOW)
raise Exception("BouncingBall should have raised ValueError because 100 is too small a window length")
except ValueError:
pass # expected error
def test_bouncing_ball_large_width_error():
try:
ball = server.BouncingBall(500, 5000, 20, server.BouncingBall.BallSpeed.SLOW)
raise Exception("BouncingBall should have raised ValueError because 3000 is too large a window length")
except ValueError:
pass # expected error
def test_bouncing_ball_slow_increment():
ball = server.BouncingBall(500, 500, 20, server.BouncingBall.BallSpeed.SLOW)
expected_x = int(500 / 4)
expected_y = int(500 / 3)
assert(ball.get_current_position() == (expected_x, expected_y))
ball.increment_ball()
assert (ball.get_current_position() == (expected_x + 1, expected_y + 1)) # Since speed is slow