mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
refactor: 移除启动缓存预热功能
删除 cache_warmup.py 及相关配置项和测试,简化启动流程
This commit is contained in:
@@ -5,54 +5,11 @@ from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
import src.services.system.cache_warmup as cache_warmup_module
|
||||
import src.services.system.maintenance_scheduler as maintenance_scheduler_module
|
||||
from src.config.settings import config
|
||||
from src.services.system.maintenance_scheduler import MaintenanceScheduler
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_cache_warmup_skips_task_when_disabled(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(config, "cache_warmup_enabled", False)
|
||||
|
||||
created = False
|
||||
|
||||
def fake_create_task(coro): # type: ignore[no-untyped-def]
|
||||
nonlocal created
|
||||
created = True
|
||||
if inspect.iscoroutine(coro):
|
||||
coro.close()
|
||||
return object()
|
||||
|
||||
monkeypatch.setattr(cache_warmup_module.asyncio, "create_task", fake_create_task)
|
||||
|
||||
await cache_warmup_module.start_cache_warmup()
|
||||
|
||||
assert created is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_cache_warmup_creates_task_when_enabled(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
monkeypatch.setattr(config, "cache_warmup_enabled", True)
|
||||
|
||||
created = False
|
||||
|
||||
def fake_create_task(coro): # type: ignore[no-untyped-def]
|
||||
nonlocal created
|
||||
created = True
|
||||
if inspect.iscoroutine(coro):
|
||||
coro.close()
|
||||
return object()
|
||||
|
||||
monkeypatch.setattr(cache_warmup_module.asyncio, "create_task", fake_create_task)
|
||||
|
||||
await cache_warmup_module.start_cache_warmup()
|
||||
|
||||
assert created is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_maintenance_scheduler_start_skips_startup_task_when_disabled(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
|
||||
Reference in New Issue
Block a user