1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
"""
This Molotov script demonstrates how to hook events.
"""
import molotov
@molotov.events()
async def print_request(event, **info):
if event == "sending_request":
print("=>")
@molotov.events()
async def print_response(event, **info):
if event == "response_received":
print("<=")
@molotov.scenario(100)
async def scenario_one(session):
async with session.get("http://localhost:8080") as resp:
res = await resp.json()
assert res["result"] == "OK"
assert resp.status == 200
|