Eli Uriegas
5577838905
Hotfixes tests failing from URL object change
...
aiohttp decided to use yarl for their new URL objects so that they
aren't plain strings anymore which means that this single test fails.
Not a huge change but this should fix the testing suite.
2017-03-22 16:21:35 -05:00
Raphael Deem
46677e69ce
accept strict_slash routes
2017-03-16 11:46:07 -07:00
Anton Zhyrnyi
410f86c960
fix for docs&tests
2017-03-14 20:53:58 +02:00
Raphael Deem
88bf78213f
Merge pull request #512 from subyraman/fix-url-building
...
Fix `request.url` and other url properties
2017-03-10 00:38:16 -08:00
Raphael Deem
c9ce33dfe6
Merge pull request #524 from r0fls/exception-list
...
allow exceptions to be a list
2017-03-10 00:35:38 -08:00
Raphael Deem
90138c4bae
return valid json in request.json
2017-03-07 18:03:45 -08:00
Raphael Deem
86c5a569d5
allow exceptions to be a list
2017-03-07 16:22:23 -08:00
Eli Uriegas
19592e8eea
Merge pull request #473 from subyraman/explore-streams-v2
...
Add `stream` method for streaming content, add docs and examples
2017-03-05 17:51:44 -08:00
Eli Uriegas
8e6678d526
Merge pull request #469 from miguelgrinberg/websocket-support
...
websocket support
2017-03-05 17:42:49 -08:00
Suby Raman
f0e818a28c
add host test
2017-03-03 13:32:32 -05:00
Suby Raman
b40f30f2e5
fix tests
2017-03-03 11:49:35 -05:00
Suby Raman
1fbde87ec2
initial commit
2017-03-03 11:44:50 -05:00
Miguel Grinberg
f90288f5dc
websocket routes in blueprints
2017-02-27 22:35:28 -08:00
Miguel Grinberg
3bf79898d9
websocket unit test
2017-02-27 22:35:28 -08:00
Raphael Deem
21fb1dff7e
fix routing issue with slashes
2017-02-27 20:01:11 -08:00
Eli Uriegas
d015d6b103
Merge pull request #476 from seemethere/inject_app_into_request
...
Inject app into request object
2017-02-23 09:12:41 -06:00
messense
91b2b40b9a
Fix test cases for requests post
2017-02-23 10:36:08 +08:00
Eli Uriegas
56ecb6a3ea
Inject app into request object
...
Allows for injection of the app object into the request object through
the request handler.
This allows for users to setup things like database connections etc. in
listeners and then utilize them throughout the their various route
handlers.
Usage is fairly simple like so:
```python
@app.get('/')
async def handler(request):
request.app.anything
```
Name is up in the air but I'll leave this up for a few days and I'll
change it if we get a consensus
2017-02-22 11:34:14 -06:00
Eli Uriegas
64f73f624f
Merge pull request #471 from r0fls/vhost-default
...
allow default vhost
2017-02-22 11:08:28 -06:00
Suby Raman
d8a6d7e02f
response.write should be synchronous for performance reasons
2017-02-22 10:42:16 -05:00
Suby Raman
4e8aac4b41
rebase
2017-02-21 11:05:06 -05:00
Raphael Deem
9c72b557ec
allow default vhost
2017-02-20 16:52:36 -08:00
Raphael Deem
207ec1e032
route logic for trailing slash
2017-02-20 16:11:28 -08:00
Suby Raman
3b68dc72e7
rework testing
2017-02-14 14:51:20 -05:00
Eli Uriegas
286dc3c32b
Merge pull request #399 from lixxu/master
...
improve url_for to support multi values and special options
2017-02-14 10:27:54 -06:00
lixxu
4839ede64f
update test for url_for and update routing.md doc
2017-02-14 10:26:30 +08:00
Raphael Deem
7a3f5d508b
fix merge conflicts
2017-02-13 14:19:44 -08:00
Eli Uriegas
1660041470
Merge pull request #408 from agoose77/master
...
Use app decorator instead of run arguments for before_start
2017-02-13 12:54:46 -06:00
Suby Raman
051ff2b325
remove repr stuff
2017-02-13 11:50:09 -05:00
Suby Raman
4d6f9ffd7c
rebase
2017-02-13 11:45:55 -05:00
Suby Raman
d614823013
rebase
2017-02-13 11:38:28 -05:00
Raphael Deem
b5e46e83e2
ensure_future -> add_task
2017-02-12 12:29:12 -08:00
Raphael Deem
94b2352c2c
add ensure_future method
2017-02-11 17:40:17 -08:00
Angus Hollands
2d5fd2fe1c
fix test
2017-02-11 14:35:44 +00:00
Angus Hollands
b5e50ecb75
Use app decorator instead of run arguments for before_start
...
Mirror listener of blueprints
2017-02-11 14:30:17 +00:00
lixxu
cf2a363e5e
improve url_for to support multi values for one arg, add _anchor/_external/_scheme options
2017-02-09 16:44:23 +08:00
Eli Uriegas
579afe012b
Fixes errors related to #378
2017-02-08 19:59:34 -06:00
Eli Uriegas
eb059183f7
Merge branch 'master' into master
2017-02-08 19:37:32 -06:00
Eli Uriegas
a5a7490bca
Merge pull request #379 from youknowone/exception
...
Let exception handler handle inherited exceptions
2017-02-08 19:20:42 -06:00
Eli Uriegas
6724d8131c
Merge pull request #387 from subyraman/url-for-v3
...
Add `url_for` method for simple routes, blueprints, HTTPMethodView
2017-02-08 19:20:09 -06:00
Jeong YunWon
413c92c631
Let exception handler handle inherited exceptions
...
Original sanic exception handler only could handle exact matching
exceptions. New `lookup` method will provide ability to looking up
their ancestors without additional cost of performance.
2017-02-07 21:08:31 +09:00
Jeong YunWon
a15ee3ad06
Fix sanic_endpoint_test working with redirects
...
Before fix, it raises error like:
```
tests/test_utils.py F
================================= FAILURES =================================
______________________________ test_redirect _______________________________
app = <sanic.sanic.Sanic object at 0x1045fda20>, method = 'get', uri = '/1', gather_request = True, debug = False
server_kwargs = {}, request_args = (), request_kwargs = {}
_collect_request = <function sanic_endpoint_test.<locals>._collect_request at 0x1045ec950>
_collect_response = <function sanic_endpoint_test.<locals>._collect_response at 0x1045ec7b8>
def sanic_endpoint_test(app, method='get', uri='/', gather_request=True,
debug=False, server_kwargs={},
*request_args, **request_kwargs):
results = []
exceptions = []
if gather_request:
def _collect_request(request):
results.append(request)
app.request_middleware.appendleft(_collect_request)
async def _collect_response(sanic, loop):
try:
response = await local_request(method, uri, *request_args,
**request_kwargs)
results.append(response)
except Exception as e:
exceptions.append(e)
app.stop()
app.run(host=HOST, debug=debug, port=PORT,
after_start=_collect_response, **server_kwargs)
if exceptions:
raise ValueError("Exception during request: {}".format(exceptions))
if gather_request:
try:
> request, response = results
E ValueError: too many values to unpack (expected 2)
sanic/utils.py:47: ValueError
During handling of the above exception, another exception occurred:
utils_app = <sanic.sanic.Sanic object at 0x1045fda20>
def test_redirect(utils_app):
"""Test sanic_endpoint_test is working for redirection"""
> request, response = sanic_endpoint_test(utils_app, uri='/1')
tests/test_utils.py:33:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
app = <sanic.sanic.Sanic object at 0x1045fda20>, method = 'get', uri = '/1', gather_request = True, debug = False
server_kwargs = {}, request_args = (), request_kwargs = {}
_collect_request = <function sanic_endpoint_test.<locals>._collect_request at 0x1045ec950>
_collect_response = <function sanic_endpoint_test.<locals>._collect_response at 0x1045ec7b8>
def sanic_endpoint_test(app, method='get', uri='/', gather_request=True,
debug=False, server_kwargs={},
*request_args, **request_kwargs):
results = []
exceptions = []
if gather_request:
def _collect_request(request):
results.append(request)
app.request_middleware.appendleft(_collect_request)
async def _collect_response(sanic, loop):
try:
response = await local_request(method, uri, *request_args,
**request_kwargs)
results.append(response)
except Exception as e:
exceptions.append(e)
app.stop()
app.run(host=HOST, debug=debug, port=PORT,
after_start=_collect_response, **server_kwargs)
if exceptions:
raise ValueError("Exception during request: {}".format(exceptions))
if gather_request:
try:
request, response = results
return request, response
except:
raise ValueError(
"Request and response object expected, got ({})".format(
> results))
E ValueError: Request and response object expected, got ([{}, {}, {}, <ClientResponse(http://127.0.0.1:42101/3 ) [200 OK]>
E <CIMultiDictProxy('Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '2', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=1')>
E ])
sanic/utils.py:52: ValueError
```
2017-02-05 13:57:04 +09:00
Suby Raman
f9056099f9
all works
2017-02-02 12:52:48 -05:00
Suby Raman
7c09ec29f7
rebase
2017-02-02 12:21:14 -05:00
Eli Uriegas
6a322ba3f8
Updates static tests to test for issue #374
...
Adds a test to test for serving a static directory at the root uri '/'
to address concerns found in #374 . Also rewrites the tests so that they
are parametrized and do more with less.
2017-02-01 09:00:57 -06:00
Eli Uriegas
487e3352e4
Revert "fix async run, add tests"
...
This reverts commit 41da793b5a
.
2017-01-31 07:30:17 -06:00
Eli Uriegas
17a92a58b2
Merge pull request #369 from r0fls/fix-async-run
...
fix async run, add tests
2017-01-30 22:21:25 -06:00
Kyle Blöm
d193a1eb70
Added the tests, code formatting changes, and the Range Request feature.
2017-01-30 17:04:51 -08:00
Raphael Deem
41da793b5a
fix async run, add tests
2017-01-29 23:47:47 -08:00
Channel Cat
b72d841619
.
2017-01-29 23:21:00 -08:00