added alias tests

Sun, 23 Jun 2019 00:38:01 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 23 Jun 2019 00:38:01 +0300
changeset 73
9664583cd1c9
parent 72
62d0b5b9d797
child 74
831d9f81a48c

added alias tests

tests/aliases.py file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/aliases.py	Sun Jun 23 00:38:01 2019 +0300
@@ -0,0 +1,42 @@
+from testsuite import problem_type, report_problem
+import linetypes
+
+@problem_type(
+    'alias-not-prefixed-with-equals',
+    severity = 'hold',
+    message = 'description of alias files must start with a "="',
+)
+@problem_type(
+    'alias-with-polygon',
+    severity = 'hold',
+    message = 'alias files must only contain subfile references',
+)
+@problem_type(
+    'alias-bad-colour',
+    severity = 'hold',
+    message = 'alias files must only use colour 16',
+)
+def alias_tests(model):
+    if model.header.valid and 'Alias' in model.header.qualifiers:
+        if not model.header.description.startswith('='):
+            yield report_problem(
+                'alias-not-prefixed-with-equals',
+                bad_object = model.body[0],
+            )
+        for element in model.body:
+            if isinstance(element, linetypes.BasePolygon):
+                yield report_problem(
+                    'alias-with-polygon',
+                    bad_object = element
+                )
+            elif hasattr(element, 'colour') and element.colour.index != 16:
+                yield report_problem(
+                    'alias-bad-colour',
+                    bad_object = element
+                )
+
+manifest = {
+    'tests': [
+        alias_tests
+    ],
+}

mercurial