Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test of static url #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.5-dev" # 3.5 development branch
- "nightly" # currently points to 3.6-dev
# command to install dependencies
install: "python setup.py install"
# command to run tests
script: "python setup.py test"
1 change: 1 addition & 0 deletions pyramid_mako/fixtures/static_url.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${request.static_url(url)}
31 changes: 31 additions & 0 deletions pyramid_mako/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,34 @@ def render_unicode(self, **values):
class DummyRendererInfo(object):
def __init__(self, kw):
self.__dict__.update(kw)


class TestRenderStaticUrl(unittest.TestCase):

def setUp(self):
self.config = testing.setUp()
self.config.include('pyramid_mako')
self.config.add_static_view('static1', 'bar:static1')
self.config.add_static_view('static2', 'static2')
self.request = testing.DummyRequest()

def tearDown(self):
self.config.end()

def test_package_relative_url(self):
from pyramid.renderers import render
url = 'bar:static1/foo'
expected = self.request.static_url(url)
result = render('fixtures/static_url.mako',
{'request': self.request, 'url': url})

self.assertEqual(result.strip(), expected)

def test_relative_url(self):
from pyramid.renderers import render
url = 'static2/foo'
expected = self.request.static_url(url)
result = render('fixtures/static_url.mako',
{'request': self.request, 'url': url})

self.assertEqual(result.strip(), expected)