tests/subfiles.py

changeset 79
eb93feb6d3a3
parent 64
1c0884f5506e
child 80
2f81758d1537
equal deleted inserted replaced
78:1970afe52da4 79:eb93feb6d3a3
204 return str.format('{} and {} dimensions', 204 return str.format('{} and {} dimensions',
205 ', '.join(sorted_dims[:-1]), 205 ', '.join(sorted_dims[:-1]),
206 sorted_dims[-1], 206 sorted_dims[-1],
207 ) 207 )
208 208
209 @problem_type('bad-category',
210 severity = 'hold',
211 message = lambda category: str.format(
212 '"{category}" is not an official category',
213 category = category,
214 )
215 )
216 def category_test(model):
217 if model.header.valid:
218 categories = library_standards['categories'].keys()
219 if model.header.effective_category not in categories:
220 try:
221 bad_object = model.find_first_header_object('category')
222 except KeyError:
223 # category was not specified using !CATEGORY, blame
224 # the description instead
225 bad_object = model.body[0]
226 yield report_problem(
227 'bad-category',
228 bad_object = bad_object,
229 category = model.header.effective_category,
230 )
231
209 manifest = { 232 manifest = {
210 'tests': [ 233 'tests': [
211 determinant_test, 234 determinant_test,
212 scaling_legality_test, 235 scaling_legality_test,
213 dependent_subfile_tests, 236 dependent_subfile_tests,
237 category_test,
214 ], 238 ],
215 } 239 }

mercurial