From fe99eb592e771fa891a697a662902042e731e216 Mon Sep 17 00:00:00 2001 From: Ntwali B Date: Tue, 29 Oct 2024 09:59:12 +0100 Subject: [PATCH 01/24] Updated email notification imports to work with CKAN 2.10. --- ckanext/dataset_subscriptions/actions/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckanext/dataset_subscriptions/actions/__init__.py b/ckanext/dataset_subscriptions/actions/__init__.py index 553adf1..4116805 100644 --- a/ckanext/dataset_subscriptions/actions/__init__.py +++ b/ckanext/dataset_subscriptions/actions/__init__.py @@ -1,8 +1,8 @@ import ckan.plugins.toolkit as toolkit import ckan.logic as logic -from ckan.lib.email_notifications import send_notification +from ckanext.activity.email_notifications import send_notification import ckanext.dataset_subscriptions.helpers as helpers -import ckan.lib.email_notifications as email_notifications +from ckanext.activity.email_notifications as email_notifications import ckan.model as model import ckan.lib.base as base from ckan.common import config From 44ae23cdd37b8339dcc6e3a5e9ce5006781be84c Mon Sep 17 00:00:00 2001 From: Ntwali B Date: Tue, 29 Oct 2024 16:25:34 +0100 Subject: [PATCH 02/24] Import fix. --- ckanext/dataset_subscriptions/actions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/dataset_subscriptions/actions/__init__.py b/ckanext/dataset_subscriptions/actions/__init__.py index 4116805..1639f3f 100644 --- a/ckanext/dataset_subscriptions/actions/__init__.py +++ b/ckanext/dataset_subscriptions/actions/__init__.py @@ -2,7 +2,7 @@ import ckan.logic as logic from ckanext.activity.email_notifications import send_notification import ckanext.dataset_subscriptions.helpers as helpers -from ckanext.activity.email_notifications as email_notifications +import ckan.activity.email_notifications as email_notifications import ckan.model as model import ckan.lib.base as base from ckan.common import config From 3b323852eda3ad74001aa9837e5fa7820f6a91c2 Mon Sep 17 00:00:00 2001 From: Ntwali B Date: Sat, 2 Nov 2024 08:24:57 +0100 Subject: [PATCH 03/24] Bug fix in import. --- ckanext/dataset_subscriptions/actions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/dataset_subscriptions/actions/__init__.py b/ckanext/dataset_subscriptions/actions/__init__.py index 1639f3f..66d7167 100644 --- a/ckanext/dataset_subscriptions/actions/__init__.py +++ b/ckanext/dataset_subscriptions/actions/__init__.py @@ -2,7 +2,7 @@ import ckan.logic as logic from ckanext.activity.email_notifications import send_notification import ckanext.dataset_subscriptions.helpers as helpers -import ckan.activity.email_notifications as email_notifications +import ckanext.activity.email_notifications as email_notifications import ckan.model as model import ckan.lib.base as base from ckan.common import config From 1fa4a0eedacdd721bfafd37c4f790a023196cbcf Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Wed, 13 Nov 2024 14:57:05 +0000 Subject: [PATCH 04/24] Simplify user_edit_form template --- .../assets/css/intlTelInput.css | 2 +- .../templates/user/edit_user_form.html | 86 +++---------------- 2 files changed, 15 insertions(+), 73 deletions(-) diff --git a/ckanext/dataset_subscriptions/assets/css/intlTelInput.css b/ckanext/dataset_subscriptions/assets/css/intlTelInput.css index f00a0ba..f39165e 100644 --- a/ckanext/dataset_subscriptions/assets/css/intlTelInput.css +++ b/ckanext/dataset_subscriptions/assets/css/intlTelInput.css @@ -77,7 +77,7 @@ .iti__flag-box, .iti__country-name { margin-right: 6px; } .iti--allow-dropdown input, .iti--allow-dropdown input[type=text], .iti--allow-dropdown input[type=tel], .iti--separate-dial-code input, .iti--separate-dial-code input[type=text], .iti--separate-dial-code input[type=tel] { - padding-right: 6px; + padding-right: 13px; padding-left: 52px; margin-left: 0; } .iti--allow-dropdown .iti__flag-container, .iti--separate-dial-code .iti__flag-container { diff --git a/ckanext/dataset_subscriptions/templates/user/edit_user_form.html b/ckanext/dataset_subscriptions/templates/user/edit_user_form.html index 7f8f9be..0487f1c 100644 --- a/ckanext/dataset_subscriptions/templates/user/edit_user_form.html +++ b/ckanext/dataset_subscriptions/templates/user/edit_user_form.html @@ -1,73 +1,15 @@ -{% import 'macros/form.html' as form %} - -{% asset "ckanext-dataset-subscriptions/user-edit-js" %} -{% asset "ckanext-dataset-subscriptions/user-edit-css" %} - -
- {{ form.errors(error_summary) }} - -
- {{ _('Change details') }} - {{ form.input('name', label=_('Username'), id='field-username', value=data.name, error=errors.name, classes=['control-medium'], attrs={'readonly': '', 'class': 'form-control'}) }} - - {{ form.input('fullname', label=_('Full name'), id='field-fullname', value=data.fullname, error=errors.fullname, placeholder=_('eg. Joe Bloggs'), classes=['control-medium']) }} - - {{ form.input('email', label=_('Email'), id='field-email', type='email', value=data.email, error=errors.email, placeholder=_('eg. joe@example.com'), classes=['control-medium'], is_required=true) }} - - {{ form.markdown('about', label=_('About'), id='field-about', value=data.about, error=errors.about, placeholder=_('A little information about yourself')) }} - - {% if show_email_notifications %} - {% call form.checkbox('activity_streams_email_notifications', label=_('Subscribe to notification emails'), id='field-activity-streams-email-notifications', value=True, checked=g.userobj.activity_streams_email_notifications) %} - {% set helper_text = _("You will receive notification emails from {site_title}, e.g. when you have new activities on your dashboard."|string) %} - {{ form.info(helper_text.format(site_title=g.site_title), classes=['info-help-tight']) }} - {% endcall %} - {% endif %} - - {{ form.input('phonenumber', label=_('Phone number'), id='field-phonenumber', type='tel', value=data.phonenumber, error=errors.phonenumber, placeholder=_('eg. +44 123123123'), classes=['control-medium'], is_required=false) }} - {% call form.checkbox('activity_streams_sms_notifications', label=_('Subscribe to sms notification'), id='field-activity-streams-sms-notifications', value=True, checked=data.activity_streams_sms_notifications) %} - {% set helper_text = _("You will receive sms notification from {site_title}, e.g. when you have new activities on your dashboard."|string) %} - {{ form.info(helper_text.format(site_title=g.site_title), classes=['info-help-tight']) }} - {% endcall %} - - {% set is_upload = data.image_url and not data.image_url.startswith('http') %} - {% set is_url = data.image_url and data.image_url.startswith('http') %} - - {{ form.image_upload(data, errors, is_upload_enabled=h.uploads_enabled(), is_url=is_url, is_upload=is_upload, upload_label=_('Profile picture'), url_label=_('Profile picture URL') ) }} - -
- -
- {{ _('Change password') }} - {{ form.input('old_password', - type='password', - label=_('Sysadmin Password') if is_sysadmin else _('Old Password'), - id='field-password-old', - value=data.oldpassword, - error=errors.oldpassword, - classes=['control-medium'], - attrs={'autocomplete': 'off', 'class': 'form-control'} - ) }} - - {{ form.input('password1', type='password', label=_('Password'), id='field-password', value=data.password1, error=errors.password1, classes=['control-medium'], attrs={'autocomplete': 'off', 'class': 'form-control'} ) }} - - {{ form.input('password2', type='password', label=_('Confirm Password'), id='field-password-confirm', value=data.password2, error=errors.password2, classes=['control-medium'], attrs={'autocomplete': 'off', 'class': 'form-control'}) }} -
- -
- {% block delete_button %} - {% if h.check_access('user_delete', {'id': data.id}) %} - {% block delete_button_text %}{{ _('Delete') }}{% endblock %} - {% endif %} - {% endblock %} - {% block generate_button %} - {% if h.check_access('user_generate_apikey', {'id': data.id}) %} - {% block generate_button_text %}{{ _('Regenerate API Key') }}{% endblock %} - {% endif %} - {% endblock %} - {{ form.required_message() }} - -
-
- -{% asset "ckanext-dataset-subscriptions/phone-number-js" %} +{% ckan_extends %} + +{% block extra_fields %} + {% asset "ckanext-dataset-subscriptions/user-edit-js" %} + {% asset "ckanext-dataset-subscriptions/user-edit-css" %} + + {{ form.input('phonenumber', label=_('Phone number'), id='field-phonenumber', type='tel', value=data.phonenumber, error=errors.phonenumber, placeholder=_('eg. +44 123123123'), classes=['control-medium'], is_required=false) }} + {% call form.checkbox('activity_streams_sms_notifications', label=_('Subscribe to SMS notification'), id='field-activity-streams-sms-notifications', value=True, checked=data.activity_streams_sms_notifications) %} + {% set helper_text = _("You will receive SMS notifications when you have new activities on your dashboard."|string) %} + {{ form.info(helper_text.format(site_title=g.site_title), classes=['info-help-tight']) }} + {% endcall %} + {{ super() }} + {% asset "ckanext-dataset-subscriptions/phone-number-js" %} +{% endblock %} From c39f3a316be5ba74793ce036f7c411de24513013 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Wed, 13 Nov 2024 15:50:10 +0000 Subject: [PATCH 05/24] Improve UI language --- .../templates/user/edit_user_form.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ckanext/dataset_subscriptions/templates/user/edit_user_form.html b/ckanext/dataset_subscriptions/templates/user/edit_user_form.html index 0487f1c..c635b94 100644 --- a/ckanext/dataset_subscriptions/templates/user/edit_user_form.html +++ b/ckanext/dataset_subscriptions/templates/user/edit_user_form.html @@ -5,11 +5,11 @@ {% asset "ckanext-dataset-subscriptions/user-edit-css" %} {{ form.input('phonenumber', label=_('Phone number'), id='field-phonenumber', type='tel', value=data.phonenumber, error=errors.phonenumber, placeholder=_('eg. +44 123123123'), classes=['control-medium'], is_required=false) }} - {% call form.checkbox('activity_streams_sms_notifications', label=_('Subscribe to SMS notification'), id='field-activity-streams-sms-notifications', value=True, checked=data.activity_streams_sms_notifications) %} - {% set helper_text = _("You will receive SMS notifications when you have new activities on your dashboard."|string) %} + {% call form.checkbox('activity_streams_sms_notifications', label=_('Subscribe to notification SMS text messages'), id='field-activity-streams-sms-notifications', value=True, checked=data.activity_streams_sms_notifications) %} + {% set helper_text = _("You will receive SMS notifications from {site_title} when you have new activities on your dashboard."|string) %} {{ form.info(helper_text.format(site_title=g.site_title), classes=['info-help-tight']) }} {% endcall %} - {{ super() }} {% asset "ckanext-dataset-subscriptions/phone-number-js" %} + {{ super() }} {% endblock %} From 692fc4654eddc2bc835a3a333f5fa499d3ddb776 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 15:21:03 +0000 Subject: [PATCH 06/24] Update github actions --- .github/workflows/test.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cab7906..05bdd56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ name: Tests -on: [pull_request] +on: [push, pull_request] jobs: test: runs-on: ubuntu-latest @@ -7,12 +7,12 @@ jobs: # The CKAN version tag of the Solr and Postgres containers should match # the one of the container the tests run on. # You can switch this base image with a custom image tailored to your project - image: openknowledge/ckan-dev:2.9 + image: ckan/ckan-base:2.11.0 services: solr: - image: ckan/ckan-solr-dev:2.9 + image: ckan/ckan-solr:2.10-solr8 postgres: - image: ckan/ckan-postgres-dev:2.9 + image: ckan/ckan-postgres-dev:2.10 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres @@ -44,5 +44,4 @@ jobs: ckan -c test.ini db init - name: Run tests - run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions - + run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From 986a1224df0b35e103419fe87553a5f2bf46c03e Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 15:35:13 +0000 Subject: [PATCH 07/24] Use correct image tags in Github actions --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05bdd56..baf1e8b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,12 +7,12 @@ jobs: # The CKAN version tag of the Solr and Postgres containers should match # the one of the container the tests run on. # You can switch this base image with a custom image tailored to your project - image: ckan/ckan-base:2.11.0 + image: ckan/ckan-base:2.11-py3.10 services: solr: - image: ckan/ckan-solr:2.10-solr8 + image: ckan/ckan-solr:2.11-solr9 postgres: - image: ckan/ckan-postgres-dev:2.10 + image: ckan/ckan-postgres-dev:2.11 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres From 3b72074c2be61d269598d7ba333638c64c6cf8c5 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 15:41:01 +0000 Subject: [PATCH 08/24] Upgrade actions/checkout --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index baf1e8b..8e16e07 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: CKAN_REDIS_URL: redis://redis:6379/1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install requirements # Install any extra requirements your extension has here (dev requirements, other extensions etc) run: | From 9968666d7ccc4f7df560bbf2150cc9b6cf0d3f4c Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 15:45:13 +0000 Subject: [PATCH 09/24] Github actions as root --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e16e07..93bce4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,7 @@ jobs: # the one of the container the tests run on. # You can switch this base image with a custom image tailored to your project image: ckan/ckan-base:2.11-py3.10 + options: --user root services: solr: image: ckan/ckan-solr:2.11-solr9 From d5aa38218c2f9f5630e2b63d88e6ce8157512196 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 15:47:57 +0000 Subject: [PATCH 10/24] Install pytest-factoryboy --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index eac82b4..8a6a304 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1 +1 @@ -pytest-ckan +pytest-factoryboy From dba9fc72777d80273dbe96d0091f9fd67202946d Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 15:53:04 +0000 Subject: [PATCH 11/24] Reinstall pytest-ckan --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index 8a6a304..dfb701d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1 +1,2 @@ +pytest-ckan pytest-factoryboy From b255de0ee2668dc543bafa35037f0227b8b844eb Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 15:55:56 +0000 Subject: [PATCH 12/24] Install pytest-cov --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index dfb701d..6aac721 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,2 +1,3 @@ pytest-ckan pytest-factoryboy +pytest-cov \ No newline at end of file From fc4a5dcb72cc6963c910af9a3e2d58e43e7bd053 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 16:03:55 +0000 Subject: [PATCH 13/24] Plugin tests require activity plugin installed --- test.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.ini b/test.ini index 347b508..8bc9b47 100644 --- a/test.ini +++ b/test.ini @@ -8,7 +8,7 @@ use = config:../ckan/test-core.ini # Insert any custom config settings to be used when running your extension's # tests here. These will override the one defined in CKAN core's test-core.ini -ckan.plugins = dataset_subscriptions +ckan.plugins = dataset_subscriptions activity ckanext.dataset_subscriptions.twilio_account_sid = dummy_sid ckanext.dataset_subscriptions.twilio_auth_token = dummy_token From ee33c5d07a660189963ee322ad7ceb72055ba19e Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 16:09:22 +0000 Subject: [PATCH 14/24] email_notifications from activity extension --- ckanext/dataset_subscriptions/tests/test_actions.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ckanext/dataset_subscriptions/tests/test_actions.py b/ckanext/dataset_subscriptions/tests/test_actions.py index ae235b5..419d2d5 100644 --- a/ckanext/dataset_subscriptions/tests/test_actions.py +++ b/ckanext/dataset_subscriptions/tests/test_actions.py @@ -1,8 +1,6 @@ from ckan.tests import factories as ckan_factories from ckanext.dataset_subscriptions.tests import factories - -import ckan.lib.email_notifications as email_notifications -import ckanext.dataset_subscriptions.actions as actions +import ckanext.activity.email_notifications as email_notifications import ckan.tests.helpers as helpers import pytest import datetime From 6dc308adabf2ae6c9699f7dfc76d2098178bc82a Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 16:25:34 +0000 Subject: [PATCH 15/24] Upgrade activity db --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93bce4f..1350e7f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: 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 - ckan -c test.ini db init + ckan -c test.ini db upgrade -p activity - name: Run tests run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From ecd9605c6c83de73fe998b3b47334f5b9a754c6f Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 16:45:24 +0000 Subject: [PATCH 16/24] Better comments --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1350e7f..21b97c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,9 @@ jobs: 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 + echo "Initialising DB" ckan -c test.ini db init - ckan -c test.ini db upgrade -p activity + echo "Upgrading DB" + ckan -c test.ini db upgrade - name: Run tests run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From 6d65155fcc4172ba6abbbabe96643441b85d29d6 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Mon, 18 Nov 2024 16:56:36 +0000 Subject: [PATCH 17/24] Try mannually upgrading the db --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 21b97c5..a571829 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,5 +46,8 @@ jobs: ckan -c test.ini db init echo "Upgrading DB" ckan -c test.ini db upgrade + psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" + psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "ALTER TABLE activity ADD COLUMN permission_labels TEXT[];" + psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" - name: Run tests run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From 7a33b527d06c5e7cac454b6844e4455dba1865cf Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 19 Nov 2024 12:01:21 +0000 Subject: [PATCH 18/24] Fix github actions --- .github/workflows/test.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a571829..b76168f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,10 +44,8 @@ jobs: sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini echo "Initialising DB" ckan -c test.ini db init + - name: Run tests + run: | echo "Upgrading DB" ckan -c test.ini db upgrade - psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" - psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "ALTER TABLE activity ADD COLUMN permission_labels TEXT[];" - psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" - - name: Run tests - run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file + pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From 2c6a82cbf66e8abf36acabe0b1c7ddd8b5441449 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 19 Nov 2024 12:04:36 +0000 Subject: [PATCH 19/24] Fix github actions --- .github/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b76168f..e63072c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,8 +44,11 @@ jobs: sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini echo "Initialising DB" ckan -c test.ini db init - - name: Run tests - run: | echo "Upgrading DB" ckan -c test.ini db upgrade - pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file + sudo apt-get install -y postgresql-client + psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" + psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "ALTER TABLE activity ADD COLUMN permission_labels TEXT[];" + psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" + - name: Run tests + run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From 22831b710617b22ff24be5f490442ac000e0f76f Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 19 Nov 2024 12:19:31 +0000 Subject: [PATCH 20/24] Fix github actions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e63072c..48687fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: ckan -c test.ini db init echo "Upgrading DB" ckan -c test.ini db upgrade - sudo apt-get install -y postgresql-client + apt-get install -y postgresql-client psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "ALTER TABLE activity ADD COLUMN permission_labels TEXT[];" psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" From f1aef8a2f039be6abfc4920beba144d7324388b1 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 19 Nov 2024 12:23:25 +0000 Subject: [PATCH 21/24] Fix github actions --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48687fe..5bfd02d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,8 +47,8 @@ jobs: echo "Upgrading DB" ckan -c test.ini db upgrade apt-get install -y postgresql-client - psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" - psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "ALTER TABLE activity ADD COLUMN permission_labels TEXT[];" - psql -Atx postgresql://ckan_default:pass@localhost/ckan_test -c "\d activity" + psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "\d activity" + psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "ALTER TABLE activity ADD COLUMN permission_labels TEXT[];" + psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "\d activity" - name: Run tests run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From 0701bab78aa6bd49450b95f0d2d5d78cd7d5ed22 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 19 Nov 2024 12:26:18 +0000 Subject: [PATCH 22/24] Fix github actions --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5bfd02d..fcb2fec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,7 +48,8 @@ jobs: ckan -c test.ini db upgrade apt-get install -y postgresql-client psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "\d activity" - psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "ALTER TABLE activity ADD COLUMN permission_labels TEXT[];" - psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "\d activity" + - name: Run tests - run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file + run: | + psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "\d activity" + pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file From b66ade52cb48c3a3fd4870ddb892e6787cb05384 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 19 Nov 2024 15:40:45 +0000 Subject: [PATCH 23/24] Migrate db for activity extension --- ckanext/dataset_subscriptions/tests/conftest.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 ckanext/dataset_subscriptions/tests/conftest.py diff --git a/ckanext/dataset_subscriptions/tests/conftest.py b/ckanext/dataset_subscriptions/tests/conftest.py new file mode 100644 index 0000000..e64b7e3 --- /dev/null +++ b/ckanext/dataset_subscriptions/tests/conftest.py @@ -0,0 +1,6 @@ +import pytest + +@pytest.fixture() +def clean_db(reset_db, migrate_db_for): + reset_db() + migrate_db_for("activity") \ No newline at end of file From b031b70a7206f679659cb0829bd993730d3393f8 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Tue, 19 Nov 2024 15:41:59 +0000 Subject: [PATCH 24/24] Simplify github actions --- .github/workflows/test.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fcb2fec..8e1f5d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,13 +43,7 @@ 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 echo "Initialising DB" - ckan -c test.ini db init - echo "Upgrading DB" - ckan -c test.ini db upgrade - apt-get install -y postgresql-client - psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "\d activity" - + ckan -c test.ini db init - name: Run tests run: | - psql -Atx postgresql://ckan_default:pass@postgres/ckan_test -c "\d activity" pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file