feat: 配置写死与 baked 模块,Alembic 建表,百度仅 BAIDU_*
- 新增 app/baked/algorithm|pipeline,非部署参数不再走 env;Settings 保留 DB/HTTP/RTSP/海康/百度/MinIO/Demo - 移除 init_db_schema 与 reload 配置;main 仅 check_database;start*.sh 在 uvicorn 前执行 alembic upgrade head - 依赖 psycopg[binary] 供 Alembic 同步 URL;alembic/env 注释与预发清单更新 - 撕段门控消费管线、各视频/语音/归档调用改为 baked - 百度环境变量仅 BAIDU_APP_ID、BAIDU_API_KEY、BAIDU_SECRET_KEY 与 BAIDU_* 超时/ASR;人脸脚本与 baidu_speech 文案同步 - 全量单测与 .env.example 更新;.gitignore 忽略 refs/(本地权重/视频不入库) Made-with: Cursor
This commit is contained in:
@@ -6,6 +6,7 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from app.baked import pipeline as bp
|
||||
from app.config import Settings
|
||||
from app.services.consumable_vision_algorithm import (
|
||||
PredictionCandidate,
|
||||
@@ -178,9 +179,11 @@ async def test_archive_retry_loop_starts() -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_skips_below_voice_floor() -> None:
|
||||
async def test_handle_skips_below_voice_floor(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
settings = Settings()
|
||||
settings.video_voice_confirm_min_confidence = 0.5
|
||||
monkeypatch.setattr(bp, "VIDEO_VOICE_CONFIRM_MIN_CONFIDENCE", 0.5)
|
||||
mgr = CameraSessionManager(
|
||||
settings=settings,
|
||||
vision_algorithm=MagicMock(),
|
||||
@@ -248,10 +251,12 @@ async def test_handle_high_conf_top1_not_in_candidates_enqueues_pending() -> Non
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_mid_confidence_enqueues_pending() -> None:
|
||||
async def test_handle_mid_confidence_enqueues_pending(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
settings = Settings()
|
||||
settings.video_auto_confirm_confidence = 0.8
|
||||
settings.video_voice_confirm_min_confidence = 0.3
|
||||
monkeypatch.setattr(bp, "VIDEO_AUTO_CONFIRM_CONFIDENCE", 0.8)
|
||||
monkeypatch.setattr(bp, "VIDEO_VOICE_CONFIRM_MIN_CONFIDENCE", 0.3)
|
||||
mgr = CameraSessionManager(
|
||||
settings=settings,
|
||||
vision_algorithm=MagicMock(),
|
||||
@@ -274,10 +279,12 @@ async def test_handle_mid_confidence_enqueues_pending() -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_voice_disabled_no_pending_for_mid_conf() -> None:
|
||||
async def test_handle_voice_disabled_no_pending_for_mid_conf(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
settings = Settings()
|
||||
settings.voice_confirmation_enabled = False
|
||||
settings.video_auto_confirm_confidence = 0.8
|
||||
monkeypatch.setattr(bp, "VOICE_CONFIRMATION_ENABLED", False)
|
||||
monkeypatch.setattr(bp, "VIDEO_AUTO_CONFIRM_CONFIDENCE", 0.8)
|
||||
mgr = CameraSessionManager(
|
||||
settings=settings,
|
||||
vision_algorithm=MagicMock(),
|
||||
@@ -296,9 +303,11 @@ async def test_handle_voice_disabled_no_pending_for_mid_conf() -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_vision_cooldown_skips_duplicate() -> None:
|
||||
async def test_handle_vision_cooldown_skips_duplicate(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
settings = Settings()
|
||||
settings.video_detail_cooldown_sec = 3600.0
|
||||
monkeypatch.setattr(bp, "VIDEO_DETAIL_COOLDOWN_SEC", 3600.0)
|
||||
mgr = CameraSessionManager(
|
||||
settings=settings,
|
||||
vision_algorithm=MagicMock(),
|
||||
@@ -317,9 +326,11 @@ async def test_handle_vision_cooldown_skips_duplicate() -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_pending_dedupe_cooldown() -> None:
|
||||
async def test_handle_pending_dedupe_cooldown(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
settings = Settings()
|
||||
settings.video_detail_cooldown_sec = 3600.0
|
||||
monkeypatch.setattr(bp, "VIDEO_DETAIL_COOLDOWN_SEC", 3600.0)
|
||||
mgr = CameraSessionManager(
|
||||
settings=settings,
|
||||
vision_algorithm=MagicMock(),
|
||||
|
||||
Reference in New Issue
Block a user