Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
47 changes: 22 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ jobs:
needs: lint
strategy:
matrix:
ckan-version: [2.8]
ckan-version: ["2.10", "2.11"]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
container:
image: openknowledge/ckan-dev:${{ matrix.ckan-version }}
image: ckan/ckan-dev:${{ matrix.ckan-version }}
options: --user root
services:
solr:
image: ckan/ckan-solr:${{ matrix.ckan-version }}
image: ckan/ckan-solr:${{ matrix.ckan-version }}-solr9
postgres:
image: ckan/ckan-postgres-dev:${{ matrix.ckan-version }}
env:
Expand All @@ -37,7 +38,7 @@ jobs:
POSTGRES_DB: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:3
image: redis:3
env:
CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test
CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test
Expand All @@ -47,25 +48,21 @@ jobs:
CKAN_SITE_URL: http://test.ckan.net

steps:
- uses: actions/checkout@v3
- name: Install requirements
run: |
# 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
pip install -r requirements.txt
pip install -r dev-requirements.txt
pip install -e .
# Last commit before support for Python 2 was dropped
pip install -e git+https://github.com/ckan/ckanext-harvest.git@v1.4.2#egg=ckanext-harvest
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/v1.4.2/requirements.txt
# Last commit before support for Python 2 was dropped
pip install -e git+https://github.com/ckan/ckanext-dcat.git@0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6#egg=ckanext-dcat
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6/requirements-py2.txt
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6/dev-requirements-py2.txt
- name: Checkout
uses: actions/checkout@v4
- name: Install requirements
run: |
pip install -r requirements.txt
pip install -r dev-requirements.txt
pip install -e .
pip install -e git+https://github.com/ckan/ckanext-harvest.git#egg=ckanext-harvest
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/master/requirements.txt
pip install -e git+https://github.com/ckan/ckanext-dcat.git#egg=ckanext-dcat
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/master/requirements.txt

- name: Setup extension
run: |
paster --plugin=ckan db init -c test.ini
paster --plugin=ckanext-harvest harvester initdb -c test.ini
- name: Run tests
run: nosetests --ckan --nocapture --nologcapture --with-pylons=test.ini --with-coverage --cover-package=ckanext.dcatapchharvest --cover-inclusive --cover-erase --cover-tests ckanext/dcatapchharvest
- name: Setup extension
run: |
ckan -c test.ini db init
ckan -c test.ini db pending-migrations --apply
- name: Run tests
run: pytest --ckan-ini=test.ini --disable-warnings --cov=ckanext.dcatapchharvest ckanext/dcatapchharvest
2 changes: 1 addition & 1 deletion ckanext/dcatapchharvest/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _add_multilang_value(
if values:
# the values can be either a multilang-dict or they are
# nested in another iterable (e.g. keywords)
if not hasattr(values, "__iter__"):
if not isinstance(values, list):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently in Python 3, strings also have the __iter__ attribute. We need to really check whether the value is a list, not check for this attribute, or we won't correctly wrap a string value in a list (in the next line) and we'll end up iterating over it letter by letter.

I think there aren't any other kinds of iterable that we could get as a value here, only a list or a string, so this should be enough of a check here.

values = [values]
for value in values:
if value:
Expand Down
Loading
Loading