-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
@@ -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) |