tests/aliases.py

Fri, 18 Sep 2020 21:41:38 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 18 Sep 2020 21:41:38 +0300
changeset 140
46cdbd4bbc32
parent 73
9664583cd1c9
child 152
5e347a96869a
permissions
-rw-r--r--

added moved to with extension unit tests

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