tests/aliases.py

Sun, 23 Jun 2019 00:42:34 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 23 Jun 2019 00:42:34 +0300
changeset 74
831d9f81a48c
parent 73
9664583cd1c9
child 152
5e347a96869a
permissions
-rw-r--r--

added a test for ".dat"-extensions in the description

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