def zabbix_fake_app(environ, start_response):
request = Request(environ)
request_body = request.get_data(as_text=True)
if getattr(zabbix_fake_app, 'status', False):
response = Response(status=zabbix_fake_app.status)
response.data = zabbix_fake_app.content
return response(environ, start_response)
response = Response(status=200, headers=[('Content-type', 'application/json')])
if '"method": "user.login"' in request_body:
json_string = '{"jsonrpc":"2.0","result":"9287f336ffb611e586aa5e5517507c66","id":0}'
elif '"method": "host.get"' in request_body:
json_string = open('tests/fixtures/host.get_success.json').read()
elif '"method": "item.get"' in request_body:
json_string = open('tests/fixtures/items.get_success.json').read()
else:
json_string = 'Unrecognized test request'
response.data = json_string
return response(environ, start_response)
评论列表
文章目录