diff --git a/src/milla/tests/test_app.py b/src/milla/tests/test_app.py index 3e7dfda..cd5b1d5 100644 --- a/src/milla/tests/test_app.py +++ b/src/milla/tests/test_app.py @@ -457,3 +457,31 @@ def test_create_href_full_keywords(): request = milla.Request(environ) url = request.create_href_full('/bar', foo='baz') assert url == 'http://127.0.0.1/bar?foo=baz' + +def test_static_resource(): + '''Request.static_resource creates valid URL from config''' + + def controller(request): + return request.static_resource('/image.png') + + environ = environ_for_testing() + app = milla.Application(StubResolver(controller)) + app.config['milla.static_root'] = '/static' + response = ResponseMaker() + app_iter = app(environ, response.start_response) + response.finish_response(app_iter) + assert response.body == b'/static/image.png', response.body + +def test_static_resource_undefined(): + '''Request.static_resource returns the path unmodified with no root defined''' + + def controller(request): + return request.static_resource('/image.png') + + environ = environ_for_testing() + app = milla.Application(StubResolver(controller)) + response = ResponseMaker() + app_iter = app(environ, response.start_response) + response.finish_response(app_iter) + assert response.body == b'/image.png', response.body + \ No newline at end of file