Skip to content

Commit 228be24

Browse files
committed
tests pass again hooray
1 parent bfa15ba commit 228be24

File tree

1 file changed

+50
-49
lines changed

1 file changed

+50
-49
lines changed

test_replays/test_all.py

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# Tests for build 17811 replays
1414

1515
def test_standard_1v1():
16-
replay = sc2reader.read_file("test_replays/1.2.2.17811/1.SC2Replay")
16+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/1.SC2Replay")
1717

1818
assert str(replay.length) == "32.47"
19-
assert replay.map == "Lost Temple"
19+
assert replay.map_name == "Lost Temple"
2020
assert replay.build == 17811
2121
assert replay.release_string == "1.2.2.17811"
2222
assert replay.speed == "Faster"
@@ -26,22 +26,22 @@ def test_standard_1v1():
2626
assert replay.is_private == False
2727

2828
assert len(replay.players) == 2
29-
assert replay.person[1].name == "Emperor"
30-
assert replay.person[2].name == "Boom"
31-
emperor = replay.person['Emperor']
29+
assert replay.person[0].name == "Emperor"
30+
assert replay.person[1].name == "Boom"
31+
emperor = replay.person[0]
3232
assert emperor.team.number == 1
3333
assert emperor.pick_race == "Protoss"
3434
assert emperor.play_race == "Protoss"
3535
assert emperor.recorder == False
3636

37-
boom = replay.person['Boom']
37+
boom = replay.person[1]
3838
assert boom.team.number == 2
3939
assert boom.pick_race == "Terran"
4040
assert boom.play_race == "Terran"
4141
assert boom.recorder == True
4242

4343
for player in replay.players:
44-
assert player.type == "Human"
44+
assert player.is_human == True
4545

4646
# Because it is a 1v1 and the recording player quit, we should know the winner.
4747
assert emperor.result == "Win"
@@ -52,93 +52,94 @@ def test_standard_1v1():
5252

5353
assert len(replay.messages) == 12
5454
assert replay.messages[0].text == "hf"
55-
assert replay.messages[0].sender.name == "Emperor"
55+
assert replay.messages[0].player.name == "Emperor"
5656
assert replay.messages[1].text == "HEYA"
57-
assert replay.messages[1].sender.name == "Boom"
57+
assert replay.messages[1].player.name == "Boom"
5858
assert replay.messages[2].text == "gl hf"
59-
assert replay.messages[2].sender.name == "Boom"
59+
assert replay.messages[2].player.name == "Boom"
6060
assert replay.messages[3].text == "sry for caps"
61-
assert replay.messages[3].sender.name == "Boom"
61+
assert replay.messages[3].player.name == "Boom"
6262
assert replay.messages[4].text == "^^"
63-
assert replay.messages[4].sender.name == "Emperor"
63+
assert replay.messages[4].player.name == "Emperor"
6464
assert replay.messages[5].text == "noppe"
65-
assert replay.messages[5].sender.name == "Emperor"
65+
assert replay.messages[5].player.name == "Emperor"
6666
assert replay.messages[6].text == "you greedy bastard"
67-
assert replay.messages[6].sender.name == "Boom"
67+
assert replay.messages[6].player.name == "Boom"
6868
assert replay.messages[7].text == "ggg"
69-
assert replay.messages[7].sender.name == "Boom"
69+
assert replay.messages[7].player.name == "Boom"
7070
assert replay.messages[8].text == "WG"
71-
assert replay.messages[8].sender.name == "Emperor"
71+
assert replay.messages[8].player.name == "Emperor"
7272
assert replay.messages[9].text == "wg? :)"
73-
assert replay.messages[9].sender.name == "Boom"
73+
assert replay.messages[9].player.name == "Boom"
7474
assert replay.messages[10].text == "wipe"
75-
assert replay.messages[10].sender.name == "Emperor"
75+
assert replay.messages[10].player.name == "Emperor"
7676
assert replay.messages[11].text == "huh?"
77-
assert replay.messages[11].sender.name == "Boom"
77+
assert replay.messages[11].player.name == "Boom"
7878

7979
for msg in replay.messages:
8080
assert msg.to_all == True
8181

8282
def test_private_category():
83-
replay = sc2reader.read_file("test_replays/1.2.2.17811/2.SC2Replay")
83+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/2.SC2Replay")
8484
assert replay.is_private == True
8585
assert replay.is_ladder == False
8686

8787
def test_3v3():
88-
replay = sc2reader.read_file("test_replays/1.2.2.17811/3.SC2Replay")
88+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/3.SC2Replay")
8989
assert replay.type == "3v3"
9090

9191
# Because it's a 3v3 and all of the members of Team 2 quit, we should know the winner.
9292
assert replay.team[1].result == "Win"
9393
assert replay.team[2].result == "Loss"
9494

9595
def test_4v4():
96-
replay = sc2reader.read_file("test_replays/1.2.0.17326/9.SC2Replay")
96+
replay = sc2reader.load_replay("test_replays/1.2.0.17326/9.SC2Replay")
9797
assert replay.type == "4v4"
9898

9999
def test_2v2():
100-
replay = sc2reader.read_file("test_replays/1.2.2.17811/7.SC2Replay")
100+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/7.SC2Replay")
101101
assert replay.type == "2v2"
102102

103103
def test_ffa():
104-
replay = sc2reader.read_file("test_replays/1.2.2.17811/8.SC2Replay")
104+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/8.SC2Replay")
105105
assert replay.type == "FFA"
106106

107-
# Player 'Boom' won because the last building of the last player was destroyed,
108-
# but the winner cannot be parsed because "Player has left" event isn't generated.
109-
# Unknown result is the best we can do.
110-
assert replay.winner_known == False
107+
assert replay.winner.players[0].name == 'Boom'
111108

112109
def test_unknown_winner():
113-
replay = sc2reader.read_file("test_replays/1.2.2.17811/10.SC2Replay")
110+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/10.SC2Replay")
114111

115112
# Recording player (Boom) left second in a 4v4, so the winner shouldn't be known
116-
assert replay.winner_known == False
113+
assert replay.winner == None
117114

118115
def test_random_player():
119-
replay = sc2reader.read_file("test_replays/1.2.2.17811/3.SC2Replay")
116+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/3.SC2Replay")
120117

121-
gogeta = replay.person['Gogeta']
118+
gogeta = next(player for player in replay.players if player.name == 'Gogeta')
122119
assert gogeta.pick_race == "Random"
123120
assert gogeta.play_race == "Terran"
124121

125122
def test_random_player2():
126-
replay = sc2reader.read_file("test_replays/1.2.2.17811/6.SC2Replay")
127-
permafrost = replay.person["Permafrost"]
123+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/6.SC2Replay")
124+
permafrost = next(player for player in replay.players if player.name == 'Permafrost')
128125
assert permafrost.pick_race == "Random"
129126
assert permafrost.play_race == "Protoss"
130127

131128
def test_us_realm():
132-
replay = sc2reader.read_file("test_replays/1.2.2.17811/5.SC2Replay")
133-
assert replay.person['ShadesofGray'].url == "http://us.battle.net/sc2/en/profile/2358439/1/ShadesofGray/"
134-
assert replay.person['reddawn'].url == "http://us.battle.net/sc2/en/profile/2198663/1/reddawn/"
129+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/5.SC2Replay")
130+
shadesofgray = next(player for player in replay.players if player.name == 'ShadesofGray')
131+
reddawn = next(player for player in replay.players if player.name == 'reddawn')
132+
assert shadesofgray.url == "http://us.battle.net/sc2/en/profile/2358439/1/ShadesofGray/"
133+
assert reddawn.url == "http://us.battle.net/sc2/en/profile/2198663/1/reddawn/"
135134

136135
# TODO: Current problem.. both players are set as the recording players
137136
# Waiting for response https://github.com/arkx/mpyq/issues/closed#issue/7
138137
def test_kr_realm_and_tampered_messages():
139-
replay = sc2reader.read_file("test_replays/1.1.3.16939/11.SC2Replay")
140-
assert replay.person['명지대학교'].url == "http://kr.battle.net/sc2/en/profile/258945/1/명지대학교/"
141-
assert replay.person['티에스엘사기수'].url == "http://kr.battle.net/sc2/en/profile/102472/1/티에스엘사기수/"
138+
replay = sc2reader.load_replay("test_replays/1.1.3.16939/11.SC2Replay")
139+
first = next(player for player in replay.players if player.name == '명지대학교')
140+
second = next(player for player in replay.players if player.name == '티에스엘사기수')
141+
assert first.url == "http://kr.battle.net/sc2/en/profile/258945/1/명지대학교/"
142+
assert second.url == "http://kr.battle.net/sc2/en/profile/102472/1/티에스엘사기수/"
142143

143144
assert replay.messages[0].text == "sc2.replays.net"
144145
assert replay.messages[5].text == "sc2.replays.net"
@@ -154,26 +155,26 @@ def test_kr_realm_and_tampered_messages():
154155
# TODO: Failing with
155156
# TypeError: Unknown event: 0x4 - 0xe3 at 16
156157
def test_referee():
157-
replay = sc2reader.read_file("test_replays/1.2.2.17811/14.SC2Replay")
158+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/14.SC2Replay")
158159

159160
def test_encrypted():
160-
replay = sc2reader.read_file("test_replays/1.2.2.17811/4.SC2Replay")
161+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/4.SC2Replay")
161162

162163
def test_observers():
163-
replay = sc2reader.read_file("test_replays/1.2.2.17811/13.SC2Replay",debug=True)
164+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/13.SC2Replay",debug=True)
164165

165166
def test_datetimes():
166167
# Ignore seconds in comparisons, because they are off by one what is reported by Windows.
167168
# This might be a little nuance worth investigating at some point.
168169

169170
# Played at 20 Feb 2011 22:44:48 UTC+2
170-
replay = sc2reader.read_file("test_replays/1.2.2.17811/1.SC2Replay")
171-
assert replay.utc_date == datetime.datetime(2011, 2, 20, 20, 44, 47)
171+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/1.SC2Replay")
172+
assert replay.end_time == datetime.datetime(2011, 2, 20, 20, 44, 47)
172173

173174
# Played at 21 Feb 2011 00:42:13 UTC+2
174-
replay = sc2reader.read_file("test_replays/1.2.2.17811/2.SC2Replay")
175-
assert replay.utc_date == datetime.datetime(2011, 2, 20, 22, 42, 12)
175+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/2.SC2Replay")
176+
assert replay.end_time == datetime.datetime(2011, 2, 20, 22, 42, 12)
176177

177178
# Played at 25 Feb 2011 16:36:28 UTC+2
178-
replay = sc2reader.read_file("test_replays/1.2.2.17811/3.SC2Replay")
179-
assert replay.utc_date == datetime.datetime(2011, 2, 25, 14, 36, 26)
179+
replay = sc2reader.load_replay("test_replays/1.2.2.17811/3.SC2Replay")
180+
assert replay.end_time == datetime.datetime(2011, 2, 25, 14, 36, 26)

0 commit comments

Comments
 (0)