Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

test(api): isolate Celery initialization app state (#44433)

Stephen Zhou851f3628100f
diff --git a/api/tests/unit_tests/extensions/test_celery_ssl.py b/api/tests/unit_tests/extensions/test_celery_ssl.py
index 7fb3ba6c8e3..24a4fac1c26 100644
--- a/api/tests/unit_tests/extensions/test_celery_ssl.py
+++ b/api/tests/unit_tests/extensions/test_celery_ssl.py
@@ -1,12 +1,24 @@
"""Tests for Celery SSL configuration."""
import ssl
+from collections.abc import Iterator
from importlib import import_module
from unittest.mock import MagicMock, patch
+import pytest
+from celery.contrib.testing.app import TestApp, setup_default_app
+
from enums import DeploymentEdition
[email protected](autouse=True)
+def restore_celery_app_state() -> Iterator[None]:
+ # init_app replaces Celery's process-wide current/default app. Restore both
+ # so later shared tasks do not enter this module's Flask app context.
+ with setup_default_app(TestApp()):
+ yield
+
+
class TestCelerySSLConfiguration:
"""Test suite for Celery SSL configuration."""