Skip to content

Commit

Permalink
Merge branch 'master' into 471-helper-clean-link-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Feb 27, 2013
2 parents 704a8cf + c493bbe commit 1730056
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 51 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -30,5 +30,7 @@ notifications:
irc:
channels:
- "irc.freenode.org#ckan"
on_success: never
on_failure: change
template:
- "%{repository} (%{branch} - %{commit}) [%{build_url}] %{author}: %{message}"
- "%{repository} %{branch} %{commit} %{build_url} %{author}: %{message}"
8 changes: 4 additions & 4 deletions ckan/controllers/package.py
Expand Up @@ -854,7 +854,7 @@ def _get_package_type(self, id):
"""
pkg = model.Package.get(id)
if pkg:
return pkg.type or 'package'
return pkg.type or 'dataset'
return None

def _tag_string_to_list(self, tag_string):
Expand Down Expand Up @@ -1004,10 +1004,10 @@ def _form_save_redirect(self, pkgname, action, package_type=None):
if url:
url = url.replace('<NAME>', pkgname)
else:
if package_type:
url = h.url_for('{0}_read'.format(package_type), id=pkgname)
else:
if package_type is None or package_type == 'dataset':
url = h.url_for(controller='package', action='read', id=pkgname)
else:
url = h.url_for('{0}_read'.format(package_type), id=pkgname)
redirect(url)

def _adjust_license_id_options(self, pkg, fs):
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/helpers.py
Expand Up @@ -85,7 +85,7 @@ def url_for(*args, **kw):
if kw.get('controller') == 'api':
ver = kw.get('ver')
if not ver:
raise Exception('api calls must specify the version! e.g. ver=1')
raise Exception('api calls must specify the version! e.g. ver=3')
# fix ver to include the slash
kw['ver'] = '/%s' % ver
my_url = _routes_default_url_for(*args, **kw)
Expand Down
6 changes: 6 additions & 0 deletions ckan/lib/jinja_extensions.py
Expand Up @@ -185,6 +185,12 @@ def get_source(self, environment, template):
continue
try:
contents = f.read().decode(self.encoding)
except UnicodeDecodeError, e:
log.critical(
'Template corruption in `%s` unicode decode errors'
% filename
)
raise e
finally:
f.close()

Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/search.html
Expand Up @@ -78,7 +78,7 @@
<section class="module">
<div class="module-content">
<small>
You can also access this registry using the {{ h.link_to(_('API'), h.url_for(controller='api', action='get_api', ver=1)) }}
You can also access this registry using the {{ h.link_to(_('API'), h.url_for(controller='api', action='get_api', ver=3)) }}
(see {{ h.link_to(_('API Docs'), 'http://docs.ckan.org/en/ckan-{0}/api.html'.format(g.ckan_base_version)) }})
{% if g.dumps_url -%}
or download a <a href="{{ g.dumps_url }}">full {{ g.dumps_format }} dump</a>
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates_legacy/package/search.html
Expand Up @@ -34,7 +34,7 @@ <h2>Other access</h2>
?>
<p>
You can also access this registry using the
${h.link_to(_('API'), h.url_for(controller='api', action='get_api', id=None, ver=1))}
${h.link_to(_('API'), h.url_for(controller='api', action='get_api', id=None, ver=3))}
(see ${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api.html')})<py:if test="dumps_url">
or download a <a href="${dumps_url}">full ${dumps_format}
dump</a></py:if>.
Expand Down
8 changes: 0 additions & 8 deletions ckan/tests/functional/api/base.py
Expand Up @@ -315,14 +315,6 @@ def assert_msg_represents_anna(self, msg):
super(Api2TestCase, self).assert_msg_represents_anna(msg)
assert 'download_url' not in msg, msg

class ApiUnversionedTestCase(Api1TestCase):

api_version = ''
oldest_api_version = 1

def get_expected_api_version(self):
return self.oldest_api_version


class BaseModelApiTestCase(ApiTestCase, ControllerTestCase):

Expand Down
3 changes: 1 addition & 2 deletions ckan/tests/functional/api/model/test_group.py
Expand Up @@ -8,7 +8,7 @@
from ckan.tests.functional.api.base import BaseModelApiTestCase
from ckan.tests.functional.api.base import Api1TestCase as Version1TestCase
from ckan.tests.functional.api.base import Api2TestCase as Version2TestCase
from ckan.tests.functional.api.base import ApiUnversionedTestCase as UnversionedTestCase


class GroupsTestCase(BaseModelApiTestCase):

Expand Down Expand Up @@ -225,4 +225,3 @@ def test_13_delete_group_404(self):

class TestGroupsVersion1(Version1TestCase, GroupsTestCase): pass
class TestGroupsVersion2(Version2TestCase, GroupsTestCase): pass
class TestGroupsUnversioned(UnversionedTestCase, GroupsTestCase): pass
2 changes: 0 additions & 2 deletions ckan/tests/functional/api/model/test_licenses.py
Expand Up @@ -6,7 +6,6 @@
from ckan.tests.functional.api.base import BaseModelApiTestCase
from ckan.tests.functional.api.base import Api1TestCase as Version1TestCase
from ckan.tests.functional.api.base import Api2TestCase as Version2TestCase
from ckan.tests.functional.api.base import ApiUnversionedTestCase as UnversionedTestCase

class LicensesTestCase(BaseModelApiTestCase):

Expand Down Expand Up @@ -35,4 +34,3 @@ def test_register_get_ok(self):

class TestLicensesVersion1(Version1TestCase, LicensesTestCase): pass
class TestLicensesVersion2(Version2TestCase, LicensesTestCase): pass
class TestLicensesUnversioned(UnversionedTestCase, LicensesTestCase): pass
2 changes: 0 additions & 2 deletions ckan/tests/functional/api/model/test_package.py
Expand Up @@ -10,7 +10,6 @@
from ckan.tests.functional.api.base import BaseModelApiTestCase
from ckan.tests.functional.api.base import Api1TestCase as Version1TestCase
from ckan.tests.functional.api.base import Api2TestCase as Version2TestCase
from ckan.tests.functional.api.base import ApiUnversionedTestCase as UnversionedTestCase

# Todo: Remove this ckan.model stuff.
import ckan.model as model
Expand Down Expand Up @@ -825,4 +824,3 @@ def test_10_edit_pkg_with_download_url(self):
assert pkg.resources[0].url == pkg_vals['download_url']

class TestPackagesVersion2(Version2TestCase, PackagesTestCase): pass
class TestPackagesUnversioned(UnversionedTestCase, PackagesTestCase): pass
2 changes: 0 additions & 2 deletions ckan/tests/functional/api/model/test_ratings.py
Expand Up @@ -7,7 +7,6 @@
from ckan.tests.functional.api.base import BaseModelApiTestCase
from ckan.tests.functional.api.base import Api1TestCase as Version1TestCase
from ckan.tests.functional.api.base import Api2TestCase as Version2TestCase
from ckan.tests.functional.api.base import ApiUnversionedTestCase as UnversionedTestCase

class RatingsTestCase(BaseModelApiTestCase):

Expand Down Expand Up @@ -101,4 +100,3 @@ def test_entity_post_invalid(self):

class TestRatingsVersion1(Version1TestCase, RatingsTestCase): pass
class TestRatingsVersion2(Version2TestCase, RatingsTestCase): pass
class TestRatingsUnversioned(UnversionedTestCase, RatingsTestCase): pass
2 changes: 0 additions & 2 deletions ckan/tests/functional/api/model/test_relationships.py
Expand Up @@ -7,7 +7,6 @@
from ckan.tests.functional.api.base import BaseModelApiTestCase
from ckan.tests.functional.api.base import Api1TestCase as Version1TestCase
from ckan.tests.functional.api.base import Api2TestCase as Version2TestCase
from ckan.tests.functional.api.base import ApiUnversionedTestCase as UnversionedTestCase

class RelationshipsTestCase(BaseModelApiTestCase):

Expand Down Expand Up @@ -327,4 +326,3 @@ def check_relationship_dict(self, rel_dict, subject_name, type, object_name, com

class TestRelationshipsVersion1(Version1TestCase, RelationshipsTestCase): pass
class TestRelationshipsVersion2(Version2TestCase, RelationshipsTestCase): pass
class TestRelationshipsUnversioned(UnversionedTestCase, RelationshipsTestCase): pass
2 changes: 0 additions & 2 deletions ckan/tests/functional/api/model/test_revisions.py
Expand Up @@ -6,7 +6,6 @@
from ckan.tests.functional.api.base import BaseModelApiTestCase
from ckan.tests.functional.api.base import Api1TestCase as Version1TestCase
from ckan.tests.functional.api.base import Api2TestCase as Version2TestCase
from ckan.tests.functional.api.base import ApiUnversionedTestCase as UnversionedTestCase

class RevisionsTestCase(BaseModelApiTestCase):

Expand Down Expand Up @@ -64,4 +63,3 @@ def test_entity_get_301(self):

class TestRevisionsVersion1(Version1TestCase, RevisionsTestCase): pass
class TestRevisionsVersion2(Version2TestCase, RevisionsTestCase): pass
class TestRevisionsUnversioned(UnversionedTestCase, RevisionsTestCase): pass
2 changes: 0 additions & 2 deletions ckan/tests/functional/api/model/test_tag.py
Expand Up @@ -9,7 +9,6 @@
from ckan.tests.functional.api.base import BaseModelApiTestCase
from ckan.tests.functional.api.base import Api1TestCase as Version1TestCase
from ckan.tests.functional.api.base import Api2TestCase as Version2TestCase
from ckan.tests.functional.api.base import ApiUnversionedTestCase as UnversionedTestCase

class TagsTestCase(BaseModelApiTestCase):

Expand Down Expand Up @@ -58,4 +57,3 @@ def test_entity_get_not_found(self):

class TestTagsVersion1(Version1TestCase, TagsTestCase): pass
class TestTagsVersion2(Version2TestCase, TagsTestCase): pass
class TestTagsUnversioned(UnversionedTestCase, TagsTestCase): pass
5 changes: 0 additions & 5 deletions ckan/tests/functional/api/test_api.py
Expand Up @@ -54,8 +54,3 @@ class TestApi1(Api1TestCase, ApiTestCase): pass

# Tests for Version 2 of the API.
class TestApi2(Api2TestCase, ApiTestCase): pass

# Tests for unversioned API.
class TestApiUnversioned(ApiUnversionedTestCase, ApiTestCase): pass


4 changes: 1 addition & 3 deletions ckan/tests/functional/api/test_misc.py
Expand Up @@ -43,6 +43,4 @@ def test_throughput(self):
class TestMiscApi1(Api1TestCase, MiscApiTestCase): pass
class TestQosApi1(Api1TestCase, QosApiTestCase): pass
class TestMiscApi2(Api2TestCase, MiscApiTestCase): pass
class TestQosApi2(Api2TestCase, QosApiTestCase): pass
class TestMiscApiUnversioned(ApiUnversionedTestCase, MiscApiTestCase): pass
class TestQosApiUnversioned(ApiUnversionedTestCase, QosApiTestCase): pass
class TestQosApi2(Api2TestCase, QosApiTestCase): pass
8 changes: 0 additions & 8 deletions ckan/tests/functional/api/test_package_search.py
Expand Up @@ -476,11 +476,3 @@ def test_13_just_groups(self):
res = self.app.get(offset, status=200)
res_dict = self.data_from_res(res)
assert res_dict['count'] == 1, res_dict


class TestPackageSearchApiUnversioned(PackageSearchApiTestCase,
ApiUnversionedTestCase,
LegacyOptionsTestCase): pass



2 changes: 0 additions & 2 deletions ckan/tests/functional/api/test_resource_search.py
Expand Up @@ -81,5 +81,3 @@ def test_05_options(self):

class TestResourceSearchApi1(Api1TestCase, ResourceSearchApiTestCase): pass
class TestResourceSearchApi2(Api2TestCase, ResourceSearchApiTestCase): pass
class TestResourceSearchApiUnversioned(ApiUnversionedTestCase, ResourceSearchApiTestCase):
pass
2 changes: 1 addition & 1 deletion ckanext/resourceproxy/controller.py
Expand Up @@ -18,7 +18,7 @@ def proxy_resource(context, data_dict):
url = resource['url']

try:
r = requests.get(url, prefetch=False)
r = requests.get(url)
r.raise_for_status()

# write body
Expand Down
2 changes: 1 addition & 1 deletion pip-requirements-test.txt
@@ -1,5 +1,5 @@
# These are packages that required when running ckan tests

nose
nose==1.2.1
-e git+https://github.com/okfn/ckanclient#egg=ckanclient

3 changes: 2 additions & 1 deletion pip-requirements.txt
Expand Up @@ -27,4 +27,5 @@ routes==1.13
paste==1.7.5.1
Jinja2==2.6
fanstatic==0.12
requests==0.14
requests==1.1.0
WebTest==1.4.3

0 comments on commit 1730056

Please sign in to comment.