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

drop ckan 2.8 test support #407

Merged
merged 1 commit into from
Apr 3, 2024
Merged
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
10 changes: 2 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
needs: lint
strategy:
matrix:
ckan-version: ["2.10", 2.9, 2.9-py2, 2.8]
ckan-version: ["2.10", "2.9", "2.9-py2"]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
Expand Down Expand Up @@ -51,16 +51,10 @@ jobs:
# Replace default path to CKAN core config file with the one on the container
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test_subclass.ini
- name: Setup extension (CKAN >= 2.9)
if: ${{ matrix.ckan-version != '2.8' }}
- name: Setup extension
run: |
pip install -r test-requirements.txt
ckan -c test.ini db init
- name: Setup extension (CKAN < 2.9)
if: ${{ matrix.ckan-version == '2.8' }}
run: |
pip install -r test-requirements-py2.txt
paster --plugin=ckan db init -c test.ini
- name: Run all tests
run: pytest --ckan-ini=test.ini --cov=ckanext.scheming ckanext/scheming/tests
- name: Run plugin subclassing tests
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Table of contents:
Requirements
============

This plugin is compatible with CKAN 2.8 or later.
This plugin is compatible with CKAN 2.9 or later.


Installation
Expand Down Expand Up @@ -397,7 +397,7 @@ If a choices list is not provided you must provide a `choices_helper`
function that will return a list of choices in the same format as
the `choices` list above.

You may [register your own helper function](https://docs.ckan.org/en/2.8/theming/templates.html#adding-your-own-template-helper-functions) or use the
You may [register your own helper function](https://docs.ckan.org/en/2.9/theming/templates.html#adding-your-own-template-helper-functions) or use the
`scheming_datastore_choices` helper included in ckanext-scheming:

```yaml
Expand Down
26 changes: 0 additions & 26 deletions ckanext/scheming/tests/mock_pylons_request.py

This file was deleted.

28 changes: 3 additions & 25 deletions ckanext/scheming/tests/test_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,14 @@ def _get_package_update_page(app, id, env):


def _get_resource_new_page(app, id, env):
if ckantoolkit.check_ckan_version(min_version="2.9"):
url = '/dataset/{}/resource/new'.format(id)
else:
url = '/dataset/new_resource/{}'.format(id)

url = '/dataset/{}/resource/new'.format(id)
return app.get(
url, extra_environ=env
)


def _get_resource_update_page(app, id, resource_id, env):
if ckantoolkit.check_ckan_version(min_version="2.9"):
url = '/dataset/{}/resource/{}/edit'.format(id, resource_id)
else:
url = '/dataset/{}/resource_edit/{}'.format(id, resource_id)
url = '/dataset/{}/resource/{}/edit'.format(id, resource_id)
return app.get(
url, extra_environ=env,
)
Expand Down Expand Up @@ -76,10 +69,7 @@ def test_dataset_form_slug_says_dataset(self, app, sysadmin_env):
def test_resource_form_includes_custom_fields(self, app, sysadmin_env):
dataset = Dataset(type="test-schema", name="resource-includes-custom")

if ckantoolkit.check_ckan_version(min_version="2.9"):
url = '/dataset/{}/resource/new'.format(dataset["id"])
else:
url = '/dataset/new_resource/{}'.format(dataset["id"])
url = '/dataset/{}/resource/new'.format(dataset["id"])

response = app.get(
url,
Expand Down Expand Up @@ -121,10 +111,6 @@ def test_organization_form_slug_says_organization(self, app, sysadmin_env):

@pytest.mark.usefixtures("clean_db")
class TestGroupFormNew(object):
@pytest.mark.skipif(
not ckantoolkit.check_ckan_version(min_version="2.7.0"),
reason="Unspecified"
)
def test_group_form_includes_custom_field(self, app, sysadmin_env):

response = _get_group_new_page(app, sysadmin_env)
Expand All @@ -144,10 +130,6 @@ def test_group_form_slug_says_group(self, app, sysadmin_env):

@pytest.mark.usefixtures("clean_db")
class TestCustomGroupFormNew(object):
@pytest.mark.skipif(
not ckantoolkit.check_ckan_version(min_version="2.8.0"),
reason="Unspecified"
)
def test_group_form_includes_custom_field(self, app, sysadmin_env):
response = _get_group_new_page(app, sysadmin_env, "theme")
form = BeautifulSoup(response.body).select("form")[1]
Expand All @@ -162,10 +144,6 @@ def test_group_form_slug_uses_custom_type(self, app, sysadmin_env):

@pytest.mark.usefixtures("clean_db")
class TestCustomOrgFormNew(object):
@pytest.mark.skipif(
not ckantoolkit.check_ckan_version(min_version="2.8.0"),
reason="Unspecified"
)
def test_org_form_includes_custom_field(self, app, sysadmin_env):
response = _get_organization_new_page(
app, sysadmin_env, "publisher"
Expand Down
23 changes: 7 additions & 16 deletions ckanext/scheming/tests/test_form_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,17 @@

import ckantoolkit

if ckantoolkit.check_ckan_version(min_version='2.9.0'):
from contextlib import contextmanager
@contextmanager
def mock_pylons_request():
yield
else:
from ckanext.scheming.tests.mock_pylons_request import mock_pylons_request


def render_form_snippet(name, data=None, extra_args=None, errors=None, **kwargs):
field = {"field_name": "test", "label": "Test"}
field.update(kwargs)
with mock_pylons_request():
return render_snippet(
"scheming/form_snippets/" + name,
field=field,
data=data or {},
errors=errors or {},
**(extra_args or {})
)
return render_snippet(
"scheming/form_snippets/" + name,
field=field,
data=data or {},
errors=errors or {},
**(extra_args or {})
)


@pytest.mark.usefixtures("with_request_context")
Expand Down
26 changes: 10 additions & 16 deletions ckanext/scheming/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
SchemingDatasetsPlugin,
SchemingGroupsPlugin,
)
from ckantoolkit import get_validator, check_ckan_version, navl_validate
from ckantoolkit import get_validator, navl_validate

ignore_missing = get_validator("ignore_missing")
not_empty = get_validator("not_empty")
Expand Down Expand Up @@ -43,21 +43,15 @@ def test_choice_field_only_accepts_given_choices(self):
type="test-schema", name="fred_choices1", category="rocker"
)
except ValidationError as e:
if check_ckan_version("2.9"):
expected = "Value must be one of {}".format(
[
u"bactrian",
u"hybrid",
u"f2hybrid",
u"snowwhite",
u"black",
]
)
else:
expected = (
"Value must be one of: bactrian; hybrid; f2hybrid; "
"snowwhite; black (not 'rocker')"
)
expected = "Value must be one of {}".format(
[
u"bactrian",
u"hybrid",
u"f2hybrid",
u"snowwhite",
u"black",
]
)
assert e.error_dict["category"] == [expected]
else:
raise AssertionError("ValidationError not raised")
Expand Down
Loading