diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55d2dc7..1cda87f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} diff --git a/ckanext/envvars/tests/test_base_envvars.py b/ckanext/envvars/tests/test_base_envvars.py index 0a33d9f..e15db8d 100644 --- a/ckanext/envvars/tests/test_base_envvars.py +++ b/ckanext/envvars/tests/test_base_envvars.py @@ -1,4 +1,7 @@ import os + +import pytest + import ckan.plugins as p import ckantoolkit as tk from ckanext.envvars.plugin import EnvvarsPlugin @@ -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'] == 'server@example.com' - # 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 @@ -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/'), @@ -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)