Thu, 26 Aug 2021 22:04:33 +0300
removed some alias tests that aren't mandated by the official header specification
from testsuite import problem_type, report_problem import linetypes @problem_type('bad-header', severity = 'hold', message = lambda reason: str.format('bad header: {}', reason), ) @problem_type('no-license-set', severity = 'hold', message = 'no license set', ) @problem_type('non-ca-license', severity = 'hold', message = 'no new non-CA-submits are accepted', ) def bad_header(model): import header ca_license = 'Redistributable under CCAL version 2.0 : see CAreadme.txt' if isinstance(model.header, header.BadHeader): yield report_problem( 'bad-header', bad_object = model.body[model.header.index], reason = model.header.reason, ) elif not model.header.license: yield report_problem( 'no-license-set', bad_object = model.body[0], ) elif model.header.license != ca_license: yield report_problem( 'non-ca-license', bad_object = model.find_first_header_object('license'), ) @problem_type('bfc-nocertify', severity = 'hold', message = 'all new parts must be BFC certified', ) def nocertify_test(model): import header if model.header.valid and model.header.bfc == 'NOCERTIFY': yield report_problem( 'bfc-nocertify', bad_object = model.find_first_header_object('bfc'), ) @problem_type('physical-colour-part', severity = 'hold', message = 'no new physical colour parts are accepted', ) def physical_colours_test(model): if model.header.valid and 'Physical_Colour' in model.header.qualifiers: yield report_problem( 'physical-colour-part', bad_object = model.find_first_header_object('part type'), ) @problem_type('unofficial-part', severity = 'hold', message = 'new parts must be unofficial', ) def unofficiality_test(model): if model.header.valid and not model.header.filetype.startswith('Unofficial_'): yield report_problem( 'unofficial-part', bad_object = model.find_first_header_object('part type') ) @problem_type('primitive-non-ccw', severity = 'hold', message = 'primitives must have CCW winding', ) @problem_type('no-bfc-line', severity = 'hold', message = 'BFC declaration is missing', ) def header_bfc_test(model): if model.header.valid and not model.header.bfc: yield report_problem( 'no-bfc-line', bad_object = model.body[0], ) elif model.header.valid \ and model.header.filetype.endswith('Primitive') \ and model.header.bfc != 'CERTIFY CCW': yield report_problem( 'primitive-non-ccw', bad_object = model.find_first_header_object('bfc'), ) @problem_type('keywords-for-nonparts', severity = 'warning', message = lambda type: str.format( 'keywords are not allowed for {type} files', type = type, ), ) def keywords_tests(model): if model.header.valid: if model.header.keywords \ and model.header.effective_filetype != 'Part': yield report_problem( 'keywords-for-nonparts', bad_object = model.find_first_header_object('keywords'), type = model.header.effective_filetype, ) @problem_type('bad-colour-24-nonline', severity = 'hold', message = 'colour 24 used on non-lines', ) @problem_type('bad-colour-24-line', severity = 'hold', message = 'line with colour other than 24', ) def colour_24_test(model): for element in model.body: if hasattr(element, 'colour'): is_line = isinstance(element, linetypes.LineSegment) if not is_line and element.colour.index == 24: yield report_problem('bad-colour-24-nonline', bad_object = element) if is_line and element.colour.index != 24: yield report_problem('bad-colour-24-line', bad_object = element) @problem_type('moved-to-with-extension', severity = 'hold', message = 'moved-to files must not contain the ' '".dat"-extension in the description', ) def moved_to_with_extension_test(model): if model.header.valid \ and model.header.description.startswith('~Moved to') \ and '.dat' in model.header.description: yield report_problem( 'moved-to-with-extension', bad_object = model.body[0], ) manifest = { 'tests': [ bad_header, nocertify_test, physical_colours_test, unofficiality_test, header_bfc_test, keywords_tests, colour_24_test, moved_to_with_extension_test, ], }