This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
tests.py
454 lines (419 loc) · 15.8 KB
/
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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
import unittest
from constants import *
from wow import *
from util import *
class BaseTest(unittest.TestCase):
def test_for_normal_query_split(self):
# Tests to ensure that the query gets split properly when the bot gets a message.
# Example query: '!armory pve/pvp <name> <realm> <region>'
sample_query = "!armory pve jimo burning-legion us"
self.assertEqual(
split_query(sample_query, "pve"), ["jimo", "burning-legion", "pve", "us"]
)
def test_for_url_query_split(self):
# Tests to ensure that the query string gets split properly when the bot gets a url based message.
# Example query: '!armory pve/pvp <armory-link> <region>' (Accepts either a world of warcraft or battle net link)
sample_wow_url = "!armory pve https://worldofwarcraft.com/en-us/character/burning-legion/jimo us"
sample_battlenet_url = "!armory pve http://us.battle.net/wow/en/character/burning-legion/jimo/advanced us"
self.assertEqual(
split_query(sample_wow_url, "pve"), ["jimo", "burning-legion", "pve", "us"]
)
self.assertEqual(
split_query(sample_battlenet_url, "pvp"),
["jimo", "burning-legion", "pvp", "us"],
)
def test_for_warrior_class(self):
# Makes sure that when the id for the Warrior class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_WARRIOR), {"colour": 0xC79C6E, "name": "Warrior"}
)
def test_for_paladin_class(self):
# Makes sure that when the id for the Paladin class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_PALADIN), {"colour": 0xF58CBA, "name": "Paladin"}
)
def test_for_hunter_class(self):
# Makes sure that when the id for the Hunter class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_HUNTER), {"colour": 0xABD473, "name": "Hunter"}
)
def test_for_rogue_class(self):
# Makes sure that when the id for the Rogue class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_ROGUE), {"colour": 0xFFF569, "name": "Rogue"}
)
def test_for_priest_class(self):
# Makes sure that when the id for the Priest class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_PRIEST), {"colour": 0xFFFFFF, "name": "Priest"}
)
def test_for_death_knight_class(self):
# Makes sure that when the id for the Death Knight class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_DEATH_KNIGHT),
{"colour": 0xC41F3B, "name": "Death Knight"},
)
def test_for_shaman_class(self):
# Makes sure that when the id for the Shaman class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_SHAMAN), {"colour": 0x0070DE, "name": "Shaman"}
)
def test_for_mage_class(self):
# Makes sure that when the id for the Mage class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_MAGE), {"colour": 0x69CCF0, "name": "Mage"}
)
def test_for_warlock_class(self):
# Makes sure that when the id for the Warlock class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_WARLOCK), {"colour": 0x9482C9, "name": "Warlock"}
)
def test_for_monk_class(self):
# Makes sure that when the id for the Monk class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_MONK), {"colour": 0x00FF96, "name": "Monk"}
)
def test_for_druid_class(self):
# Makes sure that when the id for the Druid class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_DRUID), {"colour": 0xFF7D0A, "name": "Druid"}
)
def test_for_demon_hunter_class(self):
# Makes sure that when the id for the Demon Hunter class is passed we get the
# correct name and colour.
self.assertEqual(
class_details(CLASS_DEMON_HUNTER),
{"colour": 0xA330C9, "name": "Demon Hunter"},
)
def test_for_faction_name(self):
# Makes sure that when the id for either the Horde or Alliance faction is
# passsed we get the correct name in return.
self.assertEqual(faction_details(FACTION_ALLIANCE), "Alliance")
self.assertEqual(faction_details(FACTION_HORDE), "Horde")
def test_for_achievement_progress(self):
# Passes in some mock API data and expects it to return as completed.
# Tests for accuracy on each id check, not API data.
self.maxDiff = None
input_data_horde_sample = {
"achievements": {
"achievementsCompleted": [
13418,
13419,
11611,
11162,
11185,
11184,
2090,
2093,
2092,
2091,
11194,
11581,
11195,
11874,
5356,
5353,
5349,
11191,
11192,
11874,
12110,
12111,
12536,
12535,
13079,
13448,
13322,
13323,
13784,
13780,
14068,
14144
]
}
}
input_data_alliance_sample = {
"achievements": {
"achievementsCompleted": [
13418,
11611,
11162,
11185,
11184,
2090,
2093,
2092,
2091,
11194,
11581,
11195,
11874,
5343,
5339,
5334,
11192,
11874,
11875,
12110,
12536,
13079,
13080,
13448,
13449,
13322,
13784,
13785,
13780,
13781,
14068,
14069,
14144,
14145
]
}
}
expected_horde_data = {
"keystone_season_master": "In Progress",
"keystone_season_conqueror": "Completed",
"arena_challenger": "Completed",
"arena_rival": "Completed",
"arena_duelist": "Completed",
"arena_gladiator": "Completed",
"rbg_2400_name": AC_HIGH_WARLORD_NAME,
"rbg_2000_name": AC_CHAMPION_NAME,
"rbg_1500_name": AC_FIRST_SERGEANT_NAME,
"rbg_2400": "Completed",
"rbg_2000": "Completed",
"rbg_1500": "Completed",
"ud_feat": "Cutting Edge",
"bod_feat": "Cutting Edge",
"cos_feat": "Cutting Edge",
"tep_feat": "Ahead of the Curve",
"nya_feat": "Ahead of the Curve"
}
expected_alliance_data = {
"keystone_season_master": "Completed",
"keystone_season_conqueror": "Completed",
"arena_challenger": "Completed",
"arena_rival": "Completed",
"arena_duelist": "Completed",
"arena_gladiator": "Completed",
"rbg_2400_name": AC_GRAND_MARSHALL_NAME,
"rbg_2000_name": AC_LIEAUTENANT_COMMANDER_NAME,
"rbg_1500_name": AC_SERGEANT_MAJOR_NAME,
"rbg_2400": "Completed",
"rbg_2000": "Completed",
"rbg_1500": "Completed",
"ud_feat": "Ahead of the Curve",
"bod_feat": "Ahead of the Curve",
"cos_feat": "Ahead of the Curve",
"tep_feat": "Cutting Edge",
"nya_feat": "Cutting Edge"
}
self.assertEqual(
character_achievements(input_data_horde_sample, "Horde"),
expected_horde_data,
)
self.assertEqual(
character_achievements(input_data_alliance_sample, "Alliance"),
expected_alliance_data,
)
def test_pvp_progression(self):
# Passes in some mock API data and expects it to return an object with the correct data.
# Tests for accuracy on each data check, not API data.
self.maxDiff = None
sample_data = {
"pvp": {
"brackets": {
"ARENA_BRACKET_2v2": {"rating": 5928},
"ARENA_BRACKET_3v3": {"rating": 1858},
"ARENA_BRACKET_RBG": {"rating": 5999},
"ARENA_BRACKET_2v2_SKIRMISH": {"rating": 2985},
}
},
"totalHonorableKills": 888399,
}
expected_data = {
"2v2": 5928,
"2v2s": 2985,
"3v3": 1858,
"rbg": 5999,
"kills": 888399,
}
self.assertEqual(character_arena_progress(sample_data), expected_data)
def test_pve_progression(self):
# Passes in some mock API data and expects it to return an object with the correct data.
# Tests for accuracy on each data check, not API data.
self.maxDiff = None
sample_data = {
"progression": {
"raids": [
{
"id": 9389,
"bosses": [
{
"lfrKills": 19,
"normalKills": 8,
"heroicKills": 5,
"mythicKills": 3,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 2,
},
],
},
{
"id": 8670,
"bosses": [
{
"lfrKills": 19,
"normalKills": 8,
"heroicKills": 5,
"mythicKills": 3,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 2,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 0,
},
],
},
{
"id": 10057,
"bosses": [
{
"lfrKills": 19,
"normalKills": 8,
"heroicKills": 5,
"mythicKills": 3,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 2,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 0,
},
],
},
{
"id": 10425,
"bosses": [
{
"lfrKills": 19,
"normalKills": 8,
"heroicKills": 5,
"mythicKills": 3,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 2,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 0,
},
],
},
{
"id": 10522,
"bosses": [
{
"lfrKills": 19,
"normalKills": 8,
"heroicKills": 5,
"mythicKills": 3,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 2,
},
{
"lfrKills": 3,
"normalKills": 7,
"heroicKills": 3,
"mythicKills": 0,
},
],
},
]
}
}
expected_data = {
"uldir": {"lfr": 2, "normal": 2, "heroic": 2, "mythic": 2, "bosses": 2},
"battle_of_dazaralor": {
"lfr": 3,
"normal": 3,
"heroic": 3,
"mythic": 2,
"bosses": 3,
},
"crucible_of_storms": {
"lfr": 3,
"normal": 3,
"heroic": 3,
"mythic": 2,
"bosses": 3,
},
"the_eternal_palace": {
"lfr": 3,
"normal": 3,
"heroic": 3,
"mythic": 2,
"bosses": 3,
},
"nyalotha": {
"lfr": 3,
"normal": 3,
"heroic": 3,
"mythic": 2,
"bosses": 3,
},
}
self.assertEqual(character_progression(sample_data), expected_data)
def test_player_talents(self):
# Passes in some mock API data and expects it to return an object with the correct data.
# Tests for accuracy on each data check, not API data.
sample_data = {
"talents": [
{"selected": True, "spec": {"name": "Holy", "role": "HEALING"}},
{"spec": {"name": "Shadow", "role": "DAMAGE"}},
{"spec": {"name": "Discipline", "role": "HEALING"}},
]
}
expected_data = {"active_spec": "Holy"}
self.assertEqual(character_talents(sample_data), expected_data)
if __name__ == "__main__":
unittest.main()