tests/aliases.py

changeset 152
5e347a96869a
parent 73
9664583cd1c9
equal deleted inserted replaced
151:e4401bf4a387 152:5e347a96869a
4 @problem_type( 4 @problem_type(
5 'alias-not-prefixed-with-equals', 5 'alias-not-prefixed-with-equals',
6 severity = 'hold', 6 severity = 'hold',
7 message = 'description of alias files must start with a "="', 7 message = 'description of alias files must start with a "="',
8 ) 8 )
9 @problem_type(
10 'alias-with-polygon',
11 severity = 'hold',
12 message = 'alias files must only contain subfile references',
13 )
14 @problem_type(
15 'alias-bad-colour',
16 severity = 'hold',
17 message = 'alias files must only use colour 16',
18 )
19 def alias_tests(model): 9 def alias_tests(model):
20 if model.header.valid and 'Alias' in model.header.qualifiers: 10 if model.header.valid and 'Alias' in model.header.qualifiers:
21 if not model.header.description.startswith('='): 11 if not model.header.description.startswith('='):
22 yield report_problem( 12 yield report_problem(
23 'alias-not-prefixed-with-equals', 13 'alias-not-prefixed-with-equals',
24 bad_object = model.body[0], 14 bad_object = model.body[0],
25 ) 15 )
26 for element in model.body:
27 if isinstance(element, linetypes.BasePolygon):
28 yield report_problem(
29 'alias-with-polygon',
30 bad_object = element
31 )
32 elif hasattr(element, 'colour') and element.colour.index != 16:
33 yield report_problem(
34 'alias-bad-colour',
35 bad_object = element
36 )
37 16
38 manifest = { 17 manifest = {
39 'tests': [ 18 'tests': [
40 alias_tests 19 alias_tests
41 ], 20 ],

mercurial