1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
"""Testing utilities."""
import json
def get_fixture(file: str, ext: str = 'json'):
"""Load a fixtures file."""
file_name = F"tests/fixtures/{file}.{ext}"
with open(file_name, encoding="utf-8") as open_file:
if ext == 'json':
return json.load(open_file)
return open_file.read()
def get_dispatch_handler(smartapp):
"""Get a handler to mock in the dispatcher."""
async def handler(req, resp, app):
handler.fired = True
assert app == smartapp
handler.fired = False
return handler
|