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

Fix functional tests for CKAN 2.9.x #216

Open
wants to merge 1 commit into
base: master
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
4 changes: 4 additions & 0 deletions ckanext/spatial/tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)

from ckan.plugins import toolkit

legacy_routing = toolkit.check_ckan_version(max_version='2.9')
25 changes: 21 additions & 4 deletions ckanext/spatial/tests/functional/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ckanext.spatial.model import PackageExtent
from ckanext.spatial.geoalchemy_common import legacy_geoalchemy
from ckanext.spatial.tests.base import SpatialTestBase
from ckanext.spatial.tests.functional import legacy_routing


class TestSpatialExtra(SpatialTestBase, helpers.FunctionalTestBase):
Expand All @@ -25,7 +26,11 @@ def test_spatial_extra(self):
env = {'REMOTE_USER': user['name'].encode('ascii')}
dataset = factories.Dataset(user=user)

offset = url_for(controller='package', action='edit', id=dataset['id'])
if legacy_routing:
offset = url_for(controller='package', action='edit',
id=dataset['id'])
else:
offset = url_for('dataset.edit', id=dataset['id'])
res = app.get(offset, extra_environ=env)

form = res.forms[1]
Expand Down Expand Up @@ -66,7 +71,11 @@ def test_spatial_extra_edit(self):
env = {'REMOTE_USER': user['name'].encode('ascii')}
dataset = factories.Dataset(user=user)

offset = url_for(controller='package', action='edit', id=dataset['id'])
if legacy_routing:
offset = url_for(controller='package', action='edit',
id=dataset['id'])
else:
offset = url_for('dataset.edit', id=dataset['id'])
res = app.get(offset, extra_environ=env)

form = res.forms[1]
Expand Down Expand Up @@ -113,7 +122,11 @@ def test_spatial_extra_bad_json(self):
env = {'REMOTE_USER': user['name'].encode('ascii')}
dataset = factories.Dataset(user=user)

offset = url_for(controller='package', action='edit', id=dataset['id'])
if legacy_routing:
offset = url_for(controller='package', action='edit',
id=dataset['id'])
else:
offset = url_for('dataset.edit', id=dataset['id'])
res = app.get(offset, extra_environ=env)

form = res.forms[1]
Expand All @@ -133,7 +146,11 @@ def test_spatial_extra_bad_geojson(self):
env = {'REMOTE_USER': user['name'].encode('ascii')}
dataset = factories.Dataset(user=user)

offset = url_for(controller='package', action='edit', id=dataset['id'])
if legacy_routing:
offset = url_for(controller='package', action='edit',
id=dataset['id'])
else:
offset = url_for('dataset.edit', id=dataset['id'])
res = app.get(offset, extra_environ=env)

form = res.forms[1]
Expand Down
12 changes: 10 additions & 2 deletions ckanext/spatial/tests/functional/test_widgets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ckan.lib.helpers import url_for

from ckanext.spatial.tests.base import SpatialTestBase
from ckanext.spatial.tests.functional import legacy_routing

try:
import ckan.new_tests.helpers as helpers
Expand All @@ -21,7 +22,11 @@ def test_dataset_map(self):
extras=[{'key': 'spatial',
'value': self.geojson_examples['point']}]
)
offset = url_for(controller='package', action='read', id=dataset['id'])
if legacy_routing:
offset = url_for(controller='package', action='read',
id=dataset['id'])
else:
offset = url_for('dataset.read', id=dataset['name'])
res = app.get(offset)

assert 'data-module="dataset-map"' in res
Expand All @@ -31,7 +36,10 @@ def test_spatial_search_widget(self):

app = self._get_test_app()

offset = url_for(controller='package', action='search')
if legacy_routing:
offset = url_for(controller='package', action='search')
else:
offset = url_for('dataset.search')
res = app.get(offset)

assert 'data-module="spatial-query"' in res
Expand Down