-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
82 lines (58 loc) · 1.88 KB
/
test.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from Trade import *
from Objects import *
success = "This trade is successful!"
fail = "This trade is not successful."
def test_trade(i, trade, expected_decision):
for t in trade.teams:
t.calc_money_in()
t.calc_money_out()
decisions = []
for t in trade.teams:
decision, msg = trade.check_trade(t)
decisions.append(decision)
final_decision = trade.finalize_trade(decisions)
if final_decision == expected_decision:
print("Passed test trade" + str(i))
else:
print("Failed test trade" + str(i))
#TEST 1: TOR [JV, LN] - MIA [GD] = successful
tor = Team("TOR")
mia = Team("MIA")
tor.players_out = [Player(8055, "TOR"), Player(13329, "TOR")]
mia.players_out = [Player(6146, "MIA")]
tor.players_in = mia.players_out
mia.players_in = tor.players_out
trade_teams = [tor, mia]
trade = Trade(trade_teams)
test_trade(1, trade, success)
#TEST 2: TOR[KL] - BOS[AH] = not successful (lowry resign restriction *as of 2017-09-08*)
tor = Team("TOR")
bos = Team("BOS")
tor.players_out = [Player(2536, "TOR")]
bos.players_out = [Player(2199, "BOS")]
tor.players_in = bos.players_out
bos.players_in = tor.players_out
trade_teams = [tor, bos]
trade = Trade(trade_teams)
test_trade(2, trade, fail)
#TEST 3: TOR[] - DET [AB] = not successful (tor hardcap restriction)
tor = Team("TOR")
det = Team("DET")
tor.players_out = []
det.players_out = [Player(6901, "DET")]
tor.players_in = det.players_out
det.players_in = tor.players_out
trade_teams = [tor, det]
trade = Trade(trade_teams)
test_trade(3, trade, fail)
#TEST 4: CLE[KI] - PHX[EB, JJ] = successful
cle = Team("CLE")
phx = Team("PHX")
cle.players_out = [Player(8051, "CLE")]
phx.players_out = [Player(6900, "PHX"), Player(23599, "PHX")]
cle.players_in = phx.players_out
phx.players_in = cle.players_out
trade_teams = [cle, phx]
trade = Trade(trade_teams)
test_trade(4, trade, success)
#TEST 5: