mirror of
https://github.com/langgenius/dify.git
synced 2026-11-10 21:35:45 +08:00
Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: zhaohao1004 <zhaohao1004@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: FFXN <lizy@dify.ai>
23 lines
835 B
Python
23 lines
835 B
Python
import runpy
|
|
import sys
|
|
from pathlib import Path
|
|
from types import ModuleType
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize("gevent_pool", [False, True])
|
|
def test_entrypoint_only_patches_libraries_for_a_gevent_pool(gevent_pool: bool) -> None:
|
|
fake_app = ModuleType("app")
|
|
fake_app.__dict__.update(app=object(), celery=object())
|
|
with (
|
|
patch.dict(sys.modules, {"app": fake_app}),
|
|
patch("gevent.monkey.is_module_patched", return_value=gevent_pool),
|
|
patch("grpc.experimental.gevent.init_gevent") as patch_grpc,
|
|
patch("psycogreen.gevent.patch_psycopg") as patch_psycopg,
|
|
):
|
|
runpy.run_path(str(Path(__file__).parents[2] / "celery_entrypoint.py"))
|
|
assert patch_grpc.call_count == int(gevent_pool)
|
|
assert patch_psycopg.call_count == int(gevent_pool)
|