forked from udacity/fullstack-nanodegree-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tournament_rematch_tests.py
50 lines (40 loc) · 1.19 KB
/
tournament_rematch_tests.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
#!/usr/bin/env python
#
# Test cases for rematches
from tournament import *
def testRematchAttemptisIgnored():
deleteMatches()
deletePlayers()
registerPlayer("Twilight Sparkle")
registerPlayer("Fluttershy")
standings = playerStandings()
[id1, id2] = [row[0] for row in standings]
reportMatch(id1, id2)
reportMatch(id1, id2)
id1_hist = oponentHistory(id2)
if(len(id1_hist) > 1):
raise ValueError(
"Rematches are not allowed and should be ignored"
)
else:
print 'OK - rematch ignored'
def testReverseRematchAttemptIsIgnored():
deleteMatches()
deletePlayers()
registerPlayer("Twilight Sparkle")
registerPlayer("Fluttershy")
standings = playerStandings()
[id1, id2] = [row[0] for row in standings]
reportMatch(id1, id2)
reportMatch(id2, id1)
id1_hist = oponentHistory(id2)
if(len(id1_hist) > 1):
raise ValueError(
"Reverse rematches are not allowed and should be ignored"
)
else:
print 'OK - reverse rematch ignored'
if __name__ == '__main__':
testRematchAttemptisIgnored()
testReverseRematchAttemptIsIgnored()
print "Success! tests pass!"