Skip to content

Commit ae17545

Browse files
authored
Merge pull request #117 from opendata-swiss/tests/update-tests-for-ckan-2.11-python-3
Tests/update tests for ckan 2.11 python 3
2 parents 010085a + 784c54a commit ae17545

File tree

9 files changed

+313
-375
lines changed

9 files changed

+313
-375
lines changed

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[report]
2+
omit =
3+
*/site-packages/*
4+
*/python?.?/*
5+
ckan/*
6+
*/tests/*

.github/workflows/test.yml

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ jobs:
1919
needs: lint
2020
strategy:
2121
matrix:
22-
ckan-version: [2.8]
22+
ckan-version: ["2.10", "2.11"]
2323
fail-fast: false
2424

2525
name: CKAN ${{ matrix.ckan-version }}
2626
runs-on: ubuntu-latest
2727
container:
28-
image: openknowledge/ckan-dev:${{ matrix.ckan-version }}
28+
image: ckan/ckan-dev:${{ matrix.ckan-version }}
29+
options: --user root
2930
services:
3031
solr:
31-
image: ckan/ckan-solr:${{ matrix.ckan-version }}
32+
image: ckan/ckan-solr:${{ matrix.ckan-version }}-solr9
3233
postgres:
3334
image: ckan/ckan-postgres-dev:${{ matrix.ckan-version }}
3435
env:
@@ -37,7 +38,7 @@ jobs:
3738
POSTGRES_DB: postgres
3839
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
3940
redis:
40-
image: redis:3
41+
image: redis:3
4142
env:
4243
CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test
4344
CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test
@@ -47,25 +48,23 @@ jobs:
4748
CKAN_SITE_URL: http://test.ckan.net
4849

4950
steps:
50-
- uses: actions/checkout@v3
51-
- name: Install requirements
52-
run: |
53-
# Replace default path to CKAN core config file with the one on the container
54-
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
55-
pip install -r requirements.txt
56-
pip install -r dev-requirements.txt
57-
pip install -e .
58-
# Last commit before support for Python 2 was dropped
59-
pip install -e git+https://github.com/ckan/ckanext-harvest.git@v1.4.2#egg=ckanext-harvest
60-
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/v1.4.2/requirements.txt
61-
# Last commit before support for Python 2 was dropped
62-
pip install -e git+https://github.com/ckan/ckanext-dcat.git@0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6#egg=ckanext-dcat
63-
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6/requirements-py2.txt
64-
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6/dev-requirements-py2.txt
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
- name: Install requirements
54+
run: |
55+
pip install -r requirements.txt
56+
pip install -r dev-requirements.txt
57+
pip install -e .
58+
pip install -e git+https://github.com/ckan/ckanext-harvest.git#egg=ckanext-harvest
59+
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/master/requirements.txt
60+
pip install -e git+https://github.com/ckan/ckanext-dcat.git#egg=ckanext-dcat
61+
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/master/requirements.txt
62+
# Replace default path to CKAN core config file with the one on the container
63+
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
6564
66-
- name: Setup extension
67-
run: |
68-
paster --plugin=ckan db init -c test.ini
69-
paster --plugin=ckanext-harvest harvester initdb -c test.ini
70-
- name: Run tests
71-
run: nosetests --ckan --nocapture --nologcapture --with-pylons=test.ini --with-coverage --cover-package=ckanext.dcatapchharvest --cover-inclusive --cover-erase --cover-tests ckanext/dcatapchharvest
65+
- name: Setup extension
66+
run: |
67+
ckan -c test.ini db init
68+
ckan -c test.ini db pending-migrations --apply
69+
- name: Run tests
70+
run: pytest --ckan-ini=test.ini --disable-warnings --cov=ckanext.dcatapchharvest ckanext/dcatapchharvest

ckanext/dcatapchharvest/harvesters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def before_download(self, url, harvest_job):
7171
url = url.replace("ogd.global.szh.loc", "data.stadt-zuerich.ch")
7272
return url, []
7373

74-
def _get_guid(self, dataset_dict, source_url=None):
74+
def _get_guid(self, dataset_dict, source_url=None): # noqa C901
7575
"""
7676
Try to get a unique identifier for a harvested dataset
7777
It will be the first found of:
@@ -82,6 +82,8 @@ def _get_guid(self, dataset_dict, source_url=None):
8282
The last two are obviously not optimal, as depend on title, which
8383
might change.
8484
Returns None if no guid could be decided.
85+
86+
TODO: This method is too complex (flake8 says 16). Refactor it!
8587
"""
8688
guid = None
8789

ckanext/dcatapchharvest/profiles.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _add_multilang_value(
7878
if values:
7979
# the values can be either a multilang-dict or they are
8080
# nested in another iterable (e.g. keywords)
81-
if not hasattr(values, "__iter__"):
81+
if not isinstance(values, list):
8282
values = [values]
8383
for value in values:
8484
if value:
@@ -542,7 +542,8 @@ def _get_groups(self, subject):
542542
# Deduplicate group names before returning list of group dicts
543543
return [{"name": name} for name in list(set(group_names))]
544544

545-
def parse_dataset(self, dataset_dict, dataset_ref):
545+
def parse_dataset(self, dataset_dict, dataset_ref): # noqa C901
546+
# TODO: This method is too complex (flake8 says 30). Refactor it!
546547
log.debug(f"Parsing dataset '{dataset_ref!r}'")
547548

548549
dataset_dict["temporals"] = []
@@ -760,7 +761,8 @@ def parse_dataset(self, dataset_dict, dataset_ref):
760761

761762
return dataset_dict
762763

763-
def graph_from_dataset(self, dataset_dict, dataset_ref):
764+
def graph_from_dataset(self, dataset_dict, dataset_ref): # noqa C901
765+
# TODO: This method is too complex (flake8 says 49, I am amazed). Refactor it!
764766

765767
log.debug(f"Create graph from dataset '{dataset_dict['name']}'")
766768

0 commit comments

Comments
 (0)