Skip to content

Commit

Permalink
Adapt tests ahead of CKAN 2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Oct 6, 2023
1 parent f63865e commit 413fe20
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .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, 2.7]
ckan-version: [master, "2.10", 2.9, 2.9-py2, 2.8, 2.7]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
Expand Down
35 changes: 32 additions & 3 deletions ckanext/envvars/tests/test_base_envvars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os

import pytest

import ckan.plugins as p
import ckantoolkit as tk
from ckanext.envvars.plugin import EnvvarsPlugin
Expand Down Expand Up @@ -122,8 +125,11 @@ def test_core_ckan_envvar_values_in_config(self, datastore_configure):
assert tk.config['smtp.user'] == 'my_user'
assert tk.config['smtp.password'] == 'password'
assert tk.config['smtp.mail_from'] == '[email protected]'
# See https://github.com/ckan/ckan/pull/7502
assert tk.config['smtp.starttls'] == 'True'
if tk.check_ckan_version(min_version='2.11'):
assert tk.config['smtp.starttls'] is True
else:
assert tk.config['smtp.starttls'] == 'True'


if tk.check_ckan_version(min_version='2.10'):
assert tk.config['ckan.datasets_per_page'] == 14
Expand All @@ -134,10 +140,14 @@ def test_core_ckan_envvar_values_in_config(self, datastore_configure):

self._teardown_env_vars(core_ckan_env_var_list)

@pytest.mark.skipif(tk.check_ckan_version(min_version='2.11'), reason="This does not apply to CKAN>=2.11")
@mock.patch('ckanext.datastore.plugin.DatastorePlugin.configure')
def test_core_ckan_envvar_values_in_config_take_precedence(self, datastore_configure):
'''Core CKAN env var transformations take precedence over this
extension'''
extension in CKAN<2.11
See https://github.com/ckan/ckan/pull/7502#issuecomment-1499049307
'''

combined_list = [
('CKAN___SQLALCHEMY__URL', 'postgresql://thisextensionformat/'),
Expand All @@ -149,3 +159,22 @@ def test_core_ckan_envvar_values_in_config_take_precedence(self, datastore_confi
assert tk.config['sqlalchemy.url'] == 'postgresql://coreckanformat/'

self._teardown_env_vars(combined_list)

@pytest.mark.skipif(tk.check_ckan_version(max_version='2.11'), reason="This does not apply to CKAN<2.11")
@mock.patch('ckanext.datastore.plugin.DatastorePlugin.configure')
def test_core_ckan_envvar_values_in_config_does_not_take_precedence(self, datastore_configure):
'''This extension takes precedence over Core CKAN env var transformations in CKAN>=2.11
See https://github.com/ckan/ckan/pull/7502#issuecomment-1499049307
'''

combined_list = [
('CKAN___SQLALCHEMY__URL', 'postgresql://thisextensionformat/'),
('CKAN_SQLALCHEMY_URL', 'postgresql://coreckanformat/'),
]

self._setup_env_vars(combined_list)

assert tk.config['sqlalchemy.url'] == 'postgresql://thisextensionformat/'

self._teardown_env_vars(combined_list)

0 comments on commit 413fe20

Please sign in to comment.