Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ckan_config test mark works with request context#6868

Merged
amercader merged 1 commit into
masterfrom
6841-ckan_config-mark-with-request-context
May 23, 2022
Merged

ckan_config test mark works with request context#6868
amercader merged 1 commit into
masterfrom
6841-ckan_config-mark-with-request-context

Conversation

@smotornyuk
Copy link
Copy Markdown
Member

Fixes #6841

app_globals module caches a set of the config options with their values when test execution started(just like it does every time web-server is launched). After that, every time the application object is created or the list of plugins is reloaded, the mentioned config options restore their original value, even if they were modified(via the ckan_config mark, for example)

It can be fixed by the clearing app_globals cache whenever a config object is required inside the test. But it creates another issue. Without the "initial" cached state, every change to the config object that is done directly(not via ckan_config mark or monkeypatch fixture), will affect all consequent tests. For example, code that tests overriding configuration via admin interface can set site title and all the other tests will reuse the updated title, not the original value defined by the configuration file.

That's why I'm creating a copy of the config object that was used before any test execution and resetting ckan.common.config state before each test using this snapshot.

@amercader
Copy link
Copy Markdown
Member

@smotornyuk this makes sense, but it would be nice to get rid of all that app_globals weird logic eventually

@amercader amercader merged commit 4777f3d into master May 23, 2022
@amercader amercader deleted the 6841-ckan_config-mark-with-request-context branch May 23, 2022 13:50
alexandru-m-g added a commit to OCHA-DAP/hdx-ckan that referenced this pull request Nov 3, 2022
This is related to the CKAN 2.9.7 upgrade, because of this change in CKAN core:
ckan/ckan#6868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ckan_config pytest mark doesn't work when used with the with_request_context fixture

2 participants