From 38230240867edf12fb725a5dbe081723111adfd6 Mon Sep 17 00:00:00 2001 From: Jonathan S Berry Date: Wed, 4 Dec 2024 15:11:29 +0000 Subject: [PATCH] Fix tests --- .../tests/actions/test_email_notifications.py | 1 - .../tests/actions/test_twilio_notifications.py | 10 +--------- ckanext/dataset_subscriptions/tests/conftest.py | 12 +++++++++++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ckanext/dataset_subscriptions/tests/actions/test_email_notifications.py b/ckanext/dataset_subscriptions/tests/actions/test_email_notifications.py index 9bd1ac1..9d08bc0 100644 --- a/ckanext/dataset_subscriptions/tests/actions/test_email_notifications.py +++ b/ckanext/dataset_subscriptions/tests/actions/test_email_notifications.py @@ -6,7 +6,6 @@ import datetime - @pytest.mark.ckan_config('ckan.plugins') @pytest.mark.usefixtures("with_plugins") @pytest.mark.usefixtures("clean_db") diff --git a/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py b/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py index 077392e..2f6e3a3 100644 --- a/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py +++ b/ckanext/dataset_subscriptions/tests/actions/test_twilio_notifications.py @@ -6,14 +6,6 @@ from unittest import mock -@pytest.fixture -def sysadmin_context(): - sysadmin = ckan_factories.Sysadmin() - # helpers.call_action sets 'ignore_auth' to True by default - context = {'user': sysadmin['name'], 'ignore_auth': False} - return context - - @pytest.mark.ckan_config('ckan.plugins') @pytest.mark.usefixtures("with_plugins") @pytest.mark.usefixtures("clean_db") @@ -59,7 +51,7 @@ def test_sms_notifications_disabled_enabled(notifications_enabled): @pytest.mark.usefixtures("with_plugins") @mock.patch('ckanext.dataset_subscriptions.actions.twilio_notifications.client.messages.create') def test_if_notifications_are_generated(create_message_mock, sysadmin_context): - create_user_with_resources(with_activity=True, with_notifications_enabled=True) + create_user_with_resources(True, True) expected_sid = 'SM87105da94bff44b999e4e6eb90d8eb6a' create_message_mock.return_value.sid = expected_sid sid = helpers.call_action("send_sms_notifications") diff --git a/ckanext/dataset_subscriptions/tests/conftest.py b/ckanext/dataset_subscriptions/tests/conftest.py index e64b7e3..b751d46 100644 --- a/ckanext/dataset_subscriptions/tests/conftest.py +++ b/ckanext/dataset_subscriptions/tests/conftest.py @@ -1,6 +1,16 @@ import pytest +from ckan.tests import factories as ckan_factories + + +@pytest.fixture +def sysadmin_context(): + sysadmin = ckan_factories.Sysadmin() + # helpers.call_action sets 'ignore_auth' to True by default + context = {'user': sysadmin['name'], 'ignore_auth': False} + return context + @pytest.fixture() def clean_db(reset_db, migrate_db_for): reset_db() - migrate_db_for("activity") \ No newline at end of file + migrate_db_for("activity")