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