Skip to content

Commit

Permalink
uprev and fix tests integration with aiohttp 1.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Nov 28, 2016
1 parent ff15478 commit 5623c5f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions aiohttp_devtools/runserver/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from aiohttp.hdrs import CONTENT_ENCODING, LAST_MODIFIED
from aiohttp.web_exceptions import HTTPNotFound, HTTPNotModified
from aiohttp.web_urldispatcher import StaticResource
from yarl import unquote

from ..logs import rs_aux_logger as logger
from ..logs import rs_dft_logger as dft_logger
Expand All @@ -24,6 +25,7 @@ def modify_main_app(app, config: Config):
dft_logger.debug('livereload enabled: %s', '✓' if config.livereload else '✖')
if config.livereload:
livereload_snippet = LIVE_RELOAD_SNIPPET % config.aux_port

async def on_prepare(request, response):
if not request.path.startswith('/_debugtoolbar') and 'text/html' in response.content_type:
if hasattr(response, 'body'):
Expand Down Expand Up @@ -136,7 +138,7 @@ def create_auxiliary_app(*, static_path: str, port: int, static_url='/', liverel

if static_path:
route = CustomStaticResource(
static_url,
static_url.rstrip('/'),
static_path + '/',
name='static-router',
tail_snippet=livereload_snippet,
Expand Down Expand Up @@ -261,6 +263,7 @@ def __init__(self, *args, **kwargs):
self._asset_path = None # TODO
tail_snippet = kwargs.pop('tail_snippet')
super().__init__(*args, **kwargs)
print('prefix', repr(self._prefix))
self._show_index = True
if tail_snippet:
self._file_sender = CustomFileSender(
Expand All @@ -273,7 +276,7 @@ def modify_request(self, request):
"""
Apply common path conventions eg. / > /index.html, /foobar > /foobar.html
"""
filename = request.match_info['filename']
filename = unquote(request.match_info['filename'])
raw_path = self._directory.joinpath(filename)
try:
filepath = raw_path.resolve()
Expand Down
1 change: 1 addition & 0 deletions aiohttp_devtools/start/template/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class Message(Base):
message = Column(Text)
timestamp = Column(DateTime(), server_default=func.now(), nullable=False)


sa_messages = Message.__table__
# {% endif %}
1 change: 1 addition & 0 deletions aiohttp_devtools/start/template/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def index(request):
</main>
</body>"""


async def index(request):
"""
This is the view handler for the "/" url.
Expand Down
3 changes: 2 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
coverage==4.2
docutils==0.12
flake8==3.0.4
flake8==3.2.1
ghp-import==0.4.1
pycodestyle==2.2.0
pyflakes==1.3.0
pytest==3.0.4
pytest-aiohttp==0.1.3
pytest-cov==2.4.0
Expand Down
2 changes: 2 additions & 0 deletions tests/test_runserver_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

from .conftest import SIMPLE_APP, mktree


async def test_load_simple_app(tmpworkdir):
mktree(tmpworkdir, SIMPLE_APP)
Config(app_path='app.py')


async def test_create_app_wrong_name(tmpworkdir):
mktree(tmpworkdir, SIMPLE_APP)
with pytest.raises(AiohttpDevConfigError) as excinfo:
Expand Down

0 comments on commit 5623c5f

Please sign in to comment.