def validate_analysis_result(context, ecosystem, package, version):
"""Validate results of the analysis."""
res = context.response.json()
# make sure analysis has finished
assert res['finished_at'] is not None
# we want to validate top-level analysis and worker results that have "schema" defined
structures_to_validate = [res]
for _, worker_result in res['analyses'].items():
# TODO: in future we want to mandate that all workers have their schemas,
# so we'll remove the condition
if 'schema' in worker_result:
structures_to_validate.append(worker_result)
for struct in structures_to_validate:
schema = requests.get(struct['schema']['url']).json()
jsonschema.validate(struct, schema)
common.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录