Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
emfollow
gwcelery
Commits
efd0e702
Commit
efd0e702
authored
Aug 26, 2021
by
Leo Pound Singer
Browse files
Refactor nuking of Celery backend
parent
31275f48
Changes
1
Hide whitespace changes
Inline
Side-by-side
gwcelery/tests/conftest.py
View file @
efd0e702
...
...
@@ -8,9 +8,30 @@ from .. import app
from
.process
import
starter
# noqa: F401
def
nuke_celery_backend
():
"""Clear the cached Celery backend.
Some of our tests switch backend URLs. In order for the switch to take
effect, we need to make sure that the cached backed object has been reset.
"""
try
:
del
app
.
_local
.
backend
except
AttributeError
:
pass
@
pytest
.
fixture
def
reset_celery_backend
():
nuke_celery_backend
()
yield
nuke_celery_backend
()
@
pytest
.
fixture
(
scope
=
'session'
,
autouse
=
True
)
def
noop_celery_config
():
"""Ensure that the Celery app is disconnected from live services."""
nuke_celery_backend
()
new_conf
=
dict
(
broker_url
=
'redis://redis.invalid'
,
result_backend
=
'redis://redis.invalid'
,
...
...
@@ -46,7 +67,8 @@ def celery_worker_parameters():
@
pytest
.
fixture
def
celery_app
(
celery_config
,
celery_enable_logging
,
monkeypatch
):
def
celery_app
(
celery_config
,
celery_enable_logging
,
reset_celery_backend
,
monkeypatch
):
new_conf
=
celery_config
tmp
=
{
key
:
app
.
conf
[
key
]
for
key
in
new_conf
.
keys
()}
app
.
conf
.
update
(
new_conf
)
...
...
@@ -71,12 +93,4 @@ def fake_legacy_gracedb_client(monkeypatch):
def
pytest_runtest_setup
():
# Celery caches the backend instance.
# Since we switch backends between unit tests, make sure that the cached
# backend is cleared.
try
:
del
app
.
_local
.
backend
except
AttributeError
:
pass
disable_socket
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment