Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(celery): make new FlaskCelery class work with import tests #3237

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions backend/geonature/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ def create_app(with_external_mods=True):
if "CELERY" in app.config:
from geonature.utils.celery import celery_app

# celery_app.init_app(app)
celery_app.conf.update(app.config["CELERY"])
celery_app.init_app(app)

# Emails configuration
if app.config["MAIL_CONFIG"]:
Expand Down
2 changes: 2 additions & 0 deletions backend/geonature/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
TaxrefBdcStatutText,
)
from geonature import create_app
from geonature.utils.config import config
from geonature.core.gn_commons.models import BibTablesLocation, TMedias, TModules
from geonature.core.gn_meta.models import (
CorAcquisitionFrameworkActor,
Expand Down Expand Up @@ -96,6 +97,7 @@ def open(self, *args, **kwargs):

@pytest.fixture(scope="session", autouse=True)
def app():
config["CELERY"]["task_always_eager"] = True
app = create_app()
app.testing = True
app.test_client_class = GeoNatureClient
Expand Down
5 changes: 3 additions & 2 deletions backend/geonature/utils/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
def __init__(self, *args, **kwargs):

super(FlaskCelery, self).__init__(*args, **kwargs)
self.patch_task()

if "app" in kwargs:
self.init_app(kwargs["app"])
Expand All @@ -33,6 +32,8 @@
def init_app(self, app):
self.app = app
self.config_from_object(app.config["CELERY"])
if not self.conf.task_always_eager:
self.patch_task()

Check warning on line 36 in backend/geonature/utils/celery.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/utils/celery.py#L36

Added line #L36 was not covered by tests


celery_app = Celery("geonature") # FIX ME
celery_app = FlaskCelery("geonature")
Loading