tests/aliases.py

Tue, 25 Aug 2020 21:31:41 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 25 Aug 2020 21:31:41 +0300
changeset 96
70f8049623ec
parent 73
9664583cd1c9
child 152
5e347a96869a
permissions
-rw-r--r--

move library-standards.ini to top directory

73
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 from testsuite import problem_type, report_problem
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 import linetypes
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 @problem_type(
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 'alias-not-prefixed-with-equals',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 severity = 'hold',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 message = 'description of alias files must start with a "="',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 )
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 @problem_type(
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 'alias-with-polygon',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 severity = 'hold',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 message = 'alias files must only contain subfile references',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 )
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 @problem_type(
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 'alias-bad-colour',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 severity = 'hold',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 message = 'alias files must only use colour 16',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 )
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 def alias_tests(model):
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 if model.header.valid and 'Alias' in model.header.qualifiers:
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 if not model.header.description.startswith('='):
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 yield report_problem(
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 'alias-not-prefixed-with-equals',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 bad_object = model.body[0],
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 )
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 for element in model.body:
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 if isinstance(element, linetypes.BasePolygon):
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 yield report_problem(
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 'alias-with-polygon',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 bad_object = element
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 )
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 elif hasattr(element, 'colour') and element.colour.index != 16:
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 yield report_problem(
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 'alias-bad-colour',
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35 bad_object = element
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36 )
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
38 manifest = {
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
39 'tests': [
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 alias_tests
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
41 ],
9664583cd1c9 added alias tests
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
42 }

mercurial