Skip to content

Commit

Permalink
Added a test for the url_for_static helper
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentGoderre committed Mar 30, 2016
1 parent 3bd3e2d commit f661d20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ckan/tests/lib/test_helpers.py
Expand Up @@ -35,6 +35,20 @@ def test_url_for_static_raises_when_called_with_protocol_relative(self):
url = '//assets.ckan.org/ckan.jpg'
nose.tools.assert_raises(CkanUrlException, h.url_for_static, url)

@helpers.change_config('ckan.site_url', 'http://example.com')
@helpers.change_config('ckan.root_path', '/my/custom/path/{{LANG}}/foo')
def test_url_for_static_with_root_path_and_locale(self):
url = '/my/custom/path/foo/my-asset/file.txt'
generated_url = h.url_for_static('/my-asset/file.txt')
eq_(generated_url, url)

@helpers.change_config('ckan.site_url', 'http://example.com')
@helpers.change_config('ckan.root_path', '/my/custom/path/{{LANG}}/foo')
def test_url_for_static_qualified_with_root_path_and_locale(self):
url = 'http://example.com/my/custom/path/foo/my-asset/file.txt'
generated_url = h.url_for_static('/my-asset/file.txt', qualified=True)
eq_(generated_url, url)


class TestHelpersUrlForStaticOrExternal(object):

Expand Down

0 comments on commit f661d20

Please sign in to comment.