用于验证数据系统边缘数据的库。
horkos的Python项目详细描述
霍克斯
用于验证数据系统边缘数据的库。在
安装
pip install horkos
文件
详细文档可在Read the Docs上找到。在
使用
首先定义数据架构:
^{pr2}$要使用此架构验证记录,请执行以下操作:
importhorkosschema=horkos.load_schema('http-requests-schema.yaml')schema.process({'path':'/foo/bar'})# RecordValidationError: Casting errors - params is required, method is required, ...schema.process({'path':'/foo/bar','params':'{"foo": "bar"}','method':'BAD','response_code':'200','timestamp':'2020-06-15T12:34:56',})# RecordValidationError: Check errors - "BAD" in method did not pass choice check, ...schema.process({'path':'/foo/bar','params':'{"foo": "bar"}','method':'GET','response_code':'200','timestamp':'2020-06-15T12:34:56',})# {..., 'response_code': 200, ...}
命令行接口
还可以通过cli使用horkos
来验证csv
和{
path,params,method,response_code,timestamp /foo/bar,,GET,200,2020-06-15T12:34:56 /fizbuz,{"param":"value"},POST,200,2020-12-15T12:34:56 /fizbuz,,ERROR,500,2020-12-15T12:34:56 /fizbuz,,GET,BAD,2020-12-15T12:34:56
要验证csv运行:
$ horkos check -s http-requests-schema.yaml data.csv
[Row 2]: Check errors - value of "ERROR" for method did not pass choice check
[Row 3]: Casting errors - value of "BAD" for response_code could not be cast to integer
2 errors found
- 项目
标签: