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
Eli Uriegas
6f0b09509e
Merge pull request #213 from sfstpala/master
...
Make it possible to disable the logo by subclassing Config
2017-02-01 23:07:52 -06:00
Eli Uriegas
31c53d67e2
Merge pull request #384 from seemethere/update_static_tests
...
Updates static tests to test for issue #374
2017-02-01 15:20:34 -06: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
Raphael Deem
dece636d54
Merge pull request #383 from r0fls/derp
...
typo: async_run -> run_async
2017-02-01 00:29:12 -08:00
Raphael Deem
b29f648148
typo: async_run -> run_async
2017-01-31 12:46:02 -08:00
Eli Uriegas
c91d264ff1
Merge pull request #380 from channelcat/openapi-extension
...
Added sanic-openapi to extensions
2017-01-31 07:39:38 -06:00
Eli Uriegas
487e3352e4
Revert "fix async run, add tests"
...
This reverts commit 41da793b5a
.
2017-01-31 07:30:17 -06:00
Channel Cat
34966fb182
Added sanic-openapi to extensions
2017-01-31 01:24:41 -08: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
Raphael Deem
60d3e5b9e0
Merge pull request #377 from r0fls/373
...
update route method docs
2017-01-30 17:07:26 -08:00
Raphael Deem
1501c56bbc
update route method docs
2017-01-30 16:42:43 -08:00
Eli Uriegas
6d18fb6bae
Merge pull request #363 from r0fls/run-helper
...
Run helper
2017-01-30 05:51:50 -06:00
Eli Uriegas
eac26a4514
Merge pull request #372 from JordanP/fix_docs_config
...
Fix docs/config.md: the MYAPP_SETTINGS is not exported
2017-01-30 05:43:29 -06:00
Channel Cat
1649f30808
Updated password
2017-01-30 02:22:12 -08:00
Jordan Pittier
82680bf43f
Fix docs/config.md: the MYAPP_SETTINGS is not exported
...
If we don"t `export` the variable, it's not available in subcommand:
MYAPP_SETTINGS=/path/to/config_file; python3 -c "import os; os.environ['MYAPP_SETTINGS']"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'MYAPP_SETTINGS'
The ';' is the culprit here.
2017-01-30 10:39:02 +01:00
Raphael Deem
41da793b5a
fix async run, add tests
2017-01-29 23:47:47 -08:00
Raphael Deem
cfb5734b85
Merge pull request #371 from channelcat/blueprint-shorthand
...
Blueprint route shorthand
2017-01-29 23:23:47 -08:00
Channel Cat
b72d841619
.
2017-01-29 23:21:00 -08:00
Channel Cat
0ef39f35ae
Added route shorthands to blueprints
2017-01-29 23:20:38 -08:00
Channel Cat
38d1ed76d2
Merge pull request #368 from channelcat/blueprint-clarity
...
Restructured blueprint class for clarity
2017-01-29 18:47:27 -08:00
Channel Cat
4c80cd185f
Fix flake8
2017-01-29 17:44:46 -08:00
Channel Cat
629524af04
Restructured blueprint class
...
Blueprints currently queue functions to be called, which are simple, yet
hard to inspect. These changes allow tools to be built that analyze
blueprints more easily.
2017-01-29 17:39:55 -08:00
Channel Cat
a245e54bd3
Merge pull request #367 from channelcat/fix-rtd-build
...
Fix readthedocs includes
2017-01-29 16:46:48 -08:00
Channel Cat
52e485cce9
Fix readthedocs includes
2017-01-29 16:46:16 -08:00
Channel Cat
02d374b65b
Merge pull request #365 from channelcat/fix-rtd-build
...
Adding readthedocs file
2017-01-29 16:41:41 -08:00
Channel Cat
0de6bb0063
Adding readthedocs file
2017-01-29 16:40:36 -08:00
Channel Cat
9d6b379999
Merge pull request #364 from channelcat/fix-rtd-build
...
Fix readthedocs build
2017-01-29 16:38:29 -08:00
Channel Cat
c132c4e673
fix conflict part 2
2017-01-29 16:32:57 -08:00
Channel Cat
6962dcd66c
fix conflict
2017-01-29 16:31:37 -08:00
Channel Cat
2a9496fcda
Fix readthedocs build
2017-01-29 16:25:22 -08:00
Raphael Deem
82d1d30a41
review updates
2017-01-29 14:01:00 -08:00
Eli Uriegas
85639d0806
Revert "testing"
...
This reverts commit 3fd6ecaedb
.
2017-01-29 15:55:47 -06:00
Channel Cat
3fd6ecaedb
testing
2017-01-29 13:52:17 -08:00
Channel Cat
884d3a0316
Fix RTD build
2017-01-29 13:45:44 -08:00
Raphael Deem
10dbb9186d
combine logic from create_server() and run()
2017-01-29 13:36:13 -08:00
Eli Uriegas
a547798b08
Merge pull request #360 from seemethere/fix_route_overloading_for_dynamic_routes
...
Fixes route overloading for dynamic routes
2017-01-29 15:35:13 -06:00
Eli Uriegas
894b434875
Merge pull request #362 from channelcat/read-the-docs
...
Added basic readthedocs support
2017-01-29 15:34:58 -06:00
Eli Uriegas
8db0ece459
Merge branch 'master' into read-the-docs
2017-01-29 15:31:22 -06:00
Eli Uriegas
f56c5e3a45
Merge pull request #199 from Tim-Erwin/improved_config
...
added methods to load config from a file
2017-01-29 15:27:34 -06:00
Eli Uriegas
0a5fa72099
Add logic to make dynamic route merging work
...
This is by no means the final solution but it's a start in the right
direction. Eventually what needs to happen is we need to reduce the
complexity of the routing. CompsitionView can probably be removed later
on in favor of better Route objects. Also in the next version of sanic
we need to move merge_route and add_parameter out of the add_route logic
and just have them as standalone methods.
The tests should cover everything that we need so that if any changes
are made we can identify regression.
2017-01-29 15:16:07 -06:00
Channel Cat
0eaccea38f
updated project name in docs build
2017-01-29 12:49:59 -08:00
Channel Cat
de32c389d0
Added basic readthedocs support
2017-01-29 12:47:00 -08:00
Raphael Deem
753d2da6db
fix async run
2017-01-28 15:47:29 -08:00
Eli Uriegas
d3344da9c5
Add a pesky newline
2017-01-27 22:15:34 -06:00
Eli Uriegas
ae0876876e
Switch them to verifying headers instead
2017-01-27 22:13:16 -06:00
Eli Uriegas
dea8e16f49
Force method to lower
2017-01-27 22:07:31 -06:00
Eli Uriegas
13803bdb30
Update for HTTPMethodView compatibility
2017-01-27 22:05:46 -06:00
Eli Uriegas
7257e5794f
Merge pull request #359 from r0fls/fix-warnings
...
fix deprecation warnings
2017-01-27 21:05:51 -06:00
Eli Uriegas
41c52487ee
Fixes route overloading for dynamic routes
...
Addresses #353 , now dynamic routes work alongside our newly minted
overloaded routes! Also fixed an unintended side effect where methods
were still being passed in as None for `Sanic.add_route`.
2017-01-27 21:00:33 -06:00