Fix tests and accidently removed args to serve
This commit is contained in:
parent
810008a73a
commit
825db07bf0
|
@ -64,12 +64,14 @@ def query_string(request):
|
|||
# Run Server
|
||||
# ----------------------------------------------- #
|
||||
|
||||
@app.after_start
|
||||
def after_start(app, loop):
|
||||
log.info("OH OH OH OH OHHHHHHHH")
|
||||
|
||||
|
||||
@app.before_start
|
||||
def before_stop(app, loop):
|
||||
log.info("TRIED EVERYTHING")
|
||||
|
||||
|
||||
app.run(host="0.0.0.0", port=8000, debug=True, after_start=after_start, before_stop=before_stop)
|
||||
app.run(host="0.0.0.0", port=8000, debug=True)
|
||||
|
|
|
@ -28,6 +28,7 @@ def sanic_endpoint_test(app, method='get', uri='/', gather_request=True,
|
|||
results[0] = request
|
||||
app.request_middleware.appendleft(_collect_request)
|
||||
|
||||
@app.after_start
|
||||
async def _collect_response(sanic, loop):
|
||||
try:
|
||||
response = await local_request(method, uri, *request_args,
|
||||
|
@ -37,8 +38,7 @@ def sanic_endpoint_test(app, method='get', uri='/', gather_request=True,
|
|||
exceptions.append(e)
|
||||
app.stop()
|
||||
|
||||
app.run(host=HOST, debug=debug, port=PORT,
|
||||
after_start=_collect_response, **server_kwargs)
|
||||
app.run(host=HOST, debug=debug, port=PORT, **server_kwargs)
|
||||
|
||||
if exceptions:
|
||||
raise ValueError("Exception during request: {}".format(exceptions))
|
||||
|
|
|
@ -5,6 +5,7 @@ from sanic import Sanic
|
|||
def test_bad_request_response():
|
||||
app = Sanic('test_bad_request_response')
|
||||
lines = []
|
||||
@app.after_start
|
||||
async def _request(sanic, loop):
|
||||
connect = asyncio.open_connection('127.0.0.1', 42101)
|
||||
reader, writer = await connect
|
||||
|
@ -15,6 +16,6 @@ def test_bad_request_response():
|
|||
break
|
||||
lines.append(line)
|
||||
app.stop()
|
||||
app.run(host='127.0.0.1', port=42101, debug=False, after_start=_request)
|
||||
app.run(host='127.0.0.1', port=42101, debug=False)
|
||||
assert lines[0] == b'HTTP/1.1 400 Bad Request\r\n'
|
||||
assert lines[-1] == b'Error: Bad Request'
|
||||
|
|
|
@ -27,10 +27,11 @@ def test_register_system_signals():
|
|||
async def hello_route(request):
|
||||
return HTTPResponse()
|
||||
|
||||
app.run(HOST, PORT,
|
||||
before_start=set_loop,
|
||||
after_start=stop,
|
||||
after_stop=after)
|
||||
app.after_start(stop)
|
||||
app.before_start(set_loop)
|
||||
app.after_stop(after)
|
||||
|
||||
app.run(HOST, PORT)
|
||||
assert calledq.get() == True
|
||||
|
||||
|
||||
|
@ -42,9 +43,9 @@ def test_dont_register_system_signals():
|
|||
async def hello_route(request):
|
||||
return HTTPResponse()
|
||||
|
||||
app.run(HOST, PORT,
|
||||
before_start=set_loop,
|
||||
after_start=stop,
|
||||
after_stop=after,
|
||||
register_sys_signals=False)
|
||||
app.after_start(stop)
|
||||
app.before_start(set_loop)
|
||||
app.after_stop(after)
|
||||
|
||||
app.run(HOST, PORT, register_sys_signals=False)
|
||||
assert calledq.get() == False
|
||||
|
|
Loading…
Reference in New Issue
Block a user