--- a/tests/subfiles.py Sun Jun 23 12:17:40 2019 +0300 +++ b/tests/subfiles.py Mon Jun 24 00:28:37 2019 +0300 @@ -206,10 +206,34 @@ sorted_dims[-1], ) +@problem_type('bad-category', + severity = 'hold', + message = lambda category: str.format( + '"{category}" is not an official category', + category = category, + ) +) +def category_test(model): + if model.header.valid: + categories = library_standards['categories'].keys() + if model.header.effective_category not in categories: + try: + bad_object = model.find_first_header_object('category') + except KeyError: + # category was not specified using !CATEGORY, blame + # the description instead + bad_object = model.body[0] + yield report_problem( + 'bad-category', + bad_object = bad_object, + category = model.header.effective_category, + ) + manifest = { 'tests': [ determinant_test, scaling_legality_test, dependent_subfile_tests, + category_test, ], }