Commit Graph

1089 Commits

Author SHA1 Message Date
Eli Uriegas
eb059183f7 Merge branch 'master' into master 2017-02-08 19:37:32 -06:00
Eli Uriegas
419156f7cc Merge pull request #397 from seemethere/increment_031
Increment to v0.3.1
2017-02-08 19:23:20 -06:00
Eli Uriegas
b7f7883fb7 Increment to v0.3.1 2017-02-08 19:22:51 -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
Raphael Deem
a19bb15070 Merge pull request #389 from chenfengyuan/fix_run_async_demo
fix run_async demo
2017-02-07 14:58:48 -08:00
Eli Uriegas
2ee0147848 Merge pull request #386 from youknowone/sanic_endpoint_test
Fix sanic_endpoint_test working with redirects
2017-02-07 10:57:05 -06:00
Eli Uriegas
252f1add7e Merge pull request #394 from brian-bates/tox-cleanup
Add missing dependency to tox.ini
2017-02-07 10:55:52 -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
Suby Raman
36d519026f reject unnamed handlers 2017-02-06 11:11:00 -05:00
Fengyuan Chen
aa54785918 fix always warning loop is passed issue 2017-02-06 11:11:00 -05:00
Raphael Deem
d6b386083f Merge pull request #390 from chenfengyuan/pass_loop_warning
fix always warning loop is passed issue
2017-02-05 14:01:41 -08:00
Brian Bates
82f383b64f Add missing dependency
Added missing `aiofiles` to tox.ini and cleaned up requirements files.
2017-02-05 11:44:01 -08: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
Fengyuan Chen
29680cb515 fix always warning loop is passed issue 2017-02-04 16:09:09 +08:00
Fengyuan Chen
884749f345 fix run_async demo 2017-02-04 15:27:46 +08:00
Suby Raman
5c63ce666c punctuation 2017-02-02 14:21:59 -05:00
Suby Raman
5632d073be update docs 2017-02-02 13:00:15 -05: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
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
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
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