forked from kirk24788/KPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_test.py
executable file
·62 lines (55 loc) · 2.25 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
import sys
import re
# Test if all supported Classes/Specs have meta info
print "Testing Class/Spec Meta-Data..."
from utils.config import SUPPORTED_SPECS
from utils.kps import parse_rotation_meta
exception_raised = False
for class_name in sorted(SUPPORTED_SPECS.keys()):
spec_names = sorted(SUPPORTED_SPECS[class_name])
for spec_name in spec_names:
try:
parse_rotation_meta(class_name, spec_name)
except Exception as e:
print "Test Failure: %s " % str(e)
exception_raised = True
# Test if all supported Classes/Specs contain valid spells
print "Testing Class/Spec Meta-Data..."
from utils.config import SUPPORTED_SPECS
exception_raised = False
global_spells = []
with open("modules/spell/spells.lua" , "r") as f:
data = f.read()
for line in data.split("\n"):
prefix = "kps.spells."
prefix_length = len(prefix)
if line.startswith(prefix):
global_spells.append(line[prefix_length:].split("=")[0].strip())
for class_name in sorted(SUPPORTED_SPECS.keys()):
spec_names = sorted(SUPPORTED_SPECS[class_name])
spells = list(global_spells)
with open("rotations/%s_spells.lua" % class_name, "r") as f:
data = f.read()
for line in data.split("\n"):
prefix = "kps.spells.%s." % class_name
prefix_length = len(prefix)
if line.startswith(prefix):
spells.append(line[prefix_length:].split("=")[0].strip())
for spec_name in spec_names:
rotation_file = "rotations/%s_%s.lua" % (class_name, spec_name)
with open(rotation_file, "r") as f:
line_nr = 0
data = f.read()
if "@generated_from" in data:
print "...skipping generated '%s'" % rotation_file
else:
for line in data.split("\n"):
line_nr = line_nr + 1
if "local spells" not in line:
for match in re.findall("spells\.([racial\.|ae\.]?[a-zA-Z0-9]*)", line):
if match not in spells:
print "%s:%d - Unknown 'spells.%s'" % (rotation_file, line_nr, match)
exception_raised = True
if exception_raised:
sys.exit(1)
print "...OK"