Skip to content

Commit

Permalink
Disable plugin instead of mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Sep 6, 2024
1 parent e789f56 commit dc5315c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ckanext/envvars/tests/test_base_envvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ class TestCkanCoreEnvVarsConfig(EnvVarsTestBase):
tests makes sure they still work.
'''

# The datastore plugin, only for CKAN 2.10+, will try to
# connect to the database when it is loaded.
@mock.patch('ckanext.datastore.plugin.DatastorePlugin.configure')
def test_core_ckan_envvar_values_in_config(self, datastore_configure):
def test_core_ckan_envvar_values_in_config(self):
# The datastore plugin, only for CKAN 2.10+, will try to
# connect to the database when it is loaded.

if p.plugin_loaded("datastore"):
p.unload("datastore")

core_ckan_env_var_list = [
('CKAN_SQLALCHEMY_URL', 'postgresql://mynewsqlurl/'),
Expand Down Expand Up @@ -177,13 +179,15 @@ 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.10'), reason="This does not apply to CKAN>=2.10")
@mock.patch('ckanext.datastore.plugin.DatastorePlugin.configure')
def test_core_ckan_envvar_values_in_config_take_precedence(self, datastore_configure):
def test_core_ckan_envvar_values_in_config_take_precedence(self):
'''Core CKAN env var transformations take precedence over this
extension in CKAN<2.10
See https://github.com/ckan/ckan/pull/7502#issuecomment-1499049307
'''
if p.plugin_loaded("datastore"):
p.unload("datastore")


combined_list = [
('CKAN___SQLALCHEMY__URL', 'postgresql://thisextensionformat/'),
Expand All @@ -197,12 +201,13 @@ def test_core_ckan_envvar_values_in_config_take_precedence(self, datastore_confi
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):
def test_core_ckan_envvar_values_in_config_does_not_take_precedence(self):
'''This extension takes precedence over Core CKAN env var transformations in CKAN>=2.11
See https://github.com/ckan/ckan/pull/7502#issuecomment-1499049307
'''
if p.plugin_loaded("datastore"):
p.unload("datastore")

combined_list = [
('CKAN___SQLALCHEMY__URL', 'postgresql://thisextensionformat/'),
Expand Down

0 comments on commit dc5315c

Please sign in to comment.