Skip to content

Commit

Permalink
fix tests and templates for api calls to h.url_for()
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Feb 22, 2012
1 parent 0288f4d commit 5240d79
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ckan/templates/layout_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h3 class="widget-title">About ${g.site_title}</h3>
<li>
<a href="http://twitter.com/ckanproject">Twitter @ckanproject</a>
</li>
<li>${h.link_to(_('API'), h.url_for(controller='api', action='get_api'))}</li>
<li>${h.link_to(_('API'), h.url_for(controller='api', action='get_api', ver=1))}</li>
<li>${h.link_to(_('API Docs'), 'http://wiki.ckan.net/API')}</li>
<li>
<a href="http://ckan.org/contact/">Contact Us</a>
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h4>Other access</h4>
?>
<p>
You can also access this registry using the
${h.link_to(_('API'), h.url_for(controller='api', action='get_api', id=None))}
${h.link_to(_('API'), h.url_for(controller='api', action='get_api', id=None, ver=1))}
(see ${h.link_to(_('API Docs'), 'http://wiki.ckan.net/API')})<py:if test="dumps_url">
or download a <a href="${dumps_url}">full ${dumps_format}
dump</a></py:if>.
Expand Down
6 changes: 3 additions & 3 deletions ckan/tests/functional/api/test_authorization_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def teardown(cls):

def test_autocomplete(self):
response = self.app.get(
url=url_for(controller='api', action='authorizationgroup_autocomplete'),
url=url_for(controller='api', action='authorizationgroup_autocomplete', ver=2),
params={
'q': u'anauthzgroup',
},
Expand All @@ -35,7 +35,7 @@ def test_autocomplete(self):

def test_autocomplete_multiple(self):
response = self.app.get(
url=url_for(controller='api', action='authorizationgroup_autocomplete'),
url=url_for(controller='api', action='authorizationgroup_autocomplete', ver=2),
params={
'q': u'authz',
},
Expand All @@ -46,7 +46,7 @@ def test_autocomplete_multiple(self):

def test_autocomplete_limit(self):
response = self.app.get(
url=url_for(controller='api', action='authorizationgroup_autocomplete'),
url=url_for(controller='api', action='authorizationgroup_autocomplete', ver=2),
params={
'q': u'authz',
'limit': 1
Expand Down
6 changes: 3 additions & 3 deletions ckan/tests/functional/api/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def teardown_class(cls):

def test_autocomplete(self):
response = self.app.get(
url=url_for(controller='api', action='user_autocomplete'),
url=url_for(controller='api', action='user_autocomplete', ver=2),
params={
'q': u'sysadmin',
},
Expand All @@ -29,7 +29,7 @@ def test_autocomplete(self):

def test_autocomplete_multiple(self):
response = self.app.get(
url=url_for(controller='api', action='user_autocomplete'),
url=url_for(controller='api', action='user_autocomplete', ver=2),
params={
'q': u'tes',
},
Expand All @@ -40,7 +40,7 @@ def test_autocomplete_multiple(self):

def test_autocomplete_limit(self):
response = self.app.get(
url=url_for(controller='api', action='user_autocomplete'),
url=url_for(controller='api', action='user_autocomplete', ver=2),
params={
'q': u'tes',
'limit': 1
Expand Down
20 changes: 10 additions & 10 deletions ckan/tests/functional/api/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def teardown_class(cls):

def test_package_slug_valid(self):
response = self.app.get(
url=url_for(controller='api', action='is_slug_valid'),
url=url_for(controller='api', action='is_slug_valid', ver=2),
params={
'type': u'package',
'slug': u'A New Title * With & Funny CHARacters',
Expand All @@ -28,7 +28,7 @@ def test_package_slug_valid(self):
assert_equal(response.header('Content-Type'), 'application/json;charset=utf-8')

response = self.app.get(
url=url_for(controller='api', action='is_slug_valid'),
url=url_for(controller='api', action='is_slug_valid', ver=2),
params={
'type': u'package',
'slug': u'warandpeace',
Expand All @@ -39,7 +39,7 @@ def test_package_slug_valid(self):
assert_equal(response.header('Content-Type'), 'application/json;charset=utf-8')

def test_dataset_autocomplete_match_name(self):
url = url_for(controller='api', action='dataset_autocomplete')
url = url_for(controller='api', action='dataset_autocomplete', ver=2)
assert_equal(url, '/api/2/util/dataset/autocomplete')
response = self.app.get(
url=url,
Expand All @@ -52,7 +52,7 @@ def test_dataset_autocomplete_match_name(self):
assert_equal(response.header('Content-Type'), 'application/json;charset=utf-8')

def test_dataset_autocomplete_match_title(self):
url = url_for(controller='api', action='dataset_autocomplete')
url = url_for(controller='api', action='dataset_autocomplete', ver=2)
assert_equal(url, '/api/2/util/dataset/autocomplete')
response = self.app.get(
url=url,
Expand All @@ -65,7 +65,7 @@ def test_dataset_autocomplete_match_title(self):
assert_equal(response.header('Content-Type'), 'application/json;charset=utf-8')

def test_tag_autocomplete(self):
url = url_for(controller='api', action='tag_autocomplete')
url = url_for(controller='api', action='tag_autocomplete', ver=2)
assert_equal(url, '/api/2/util/tag/autocomplete')
response = self.app.get(
url=url,
Expand All @@ -80,39 +80,39 @@ def test_tag_autocomplete(self):
def test_markdown(self):
markdown = '''##Title'''
response = self.app.get(
url=url_for(controller='api', action='markdown'),
url=url_for(controller='api', action='markdown', ver=2),
params={'q': markdown},
status=200,
)
assert_equal(response.body, '"<h2>Title</h2>"')

def test_munge_package_name(self):
response = self.app.get(
url=url_for(controller='api', action='munge_package_name'),
url=url_for(controller='api', action='munge_package_name', ver=2),
params={'name': 'test name'},
status=200,
)
assert_equal(response.body, '"test-name"')

def test_munge_title_to_package_name(self):
response = self.app.get(
url=url_for(controller='api', action='munge_title_to_package_name'),
url=url_for(controller='api', action='munge_title_to_package_name', ver=2),
params={'name': 'Test title'},
status=200,
)
assert_equal(response.body, '"test-title"')

def test_munge_tag(self):
response = self.app.get(
url=url_for(controller='api', action='munge_tag'),
url=url_for(controller='api', action='munge_tag', ver=2),
params={'name': 'Test subject'},
status=200,
)
assert_equal(response.body, '"test-subject"')

def test_status(self):
response = self.app.get(
url=url_for(controller='api', action='status'),
url=url_for(controller='api', action='status', ver=2),
params={},
status=200,
)
Expand Down

0 comments on commit 5240d79

Please sign in to comment.