Files
OpenMesh/tests/conftest.py
zhaolei 6f402ffcee
Some checks failed
CI / pytest (push) Has been cancelled
CI / gui-unit (push) Has been cancelled
CI / gui-e2e (push) Has been cancelled
feat: OpenMesh 基础平台与 MD/PDF 转换技能
- 后端: coworker 智能体框架, WS API, 文件上传, 附件处理
- 前端: Open WebUI, 文件全量走 upload API (含 MD/TXT/JSON 等文本类)
- 技能: md-to-office (pandoc + wkhtmltopdf)
- 修复: 上传文件路径丢失, Agent 搜索浪费, 输出文件跑到 uploads/
- 打包: PyInstaller one-dir, 预打包 pandoc/wkhtmltopdf/chromium
2026-09-13 23:41:04 +08:00

40 lines
1.6 KiB
Python

"""Shared pytest fixtures.
`fake_slack` boots the in-process FakeSlack harness on an ephemeral port and points the Slack
adapter at it via `SLACK_API_URL`, so the real `SlackAdapter` / `slack_bolt` stack runs
end-to-end with no network, tokens, or the Slack app console. See
`coworker.testing.fake_slack` and `platform/docs/FAKE-SLACK-SPEC.md`.
"""
from __future__ import annotations
import pytest
import pytest_asyncio
from coworker.testing.fake_slack import FakeSlack
@pytest.fixture(autouse=True)
def _isolated_state_dir(tmp_path, monkeypatch):
"""EVERY test gets an isolated SecretStore/state dir. Without this, any test that builds
a SessionManager reads the developer's real machine-global state — including their cloud
sign-in, which made test session creation emit REAL telemetry to prod (found 2026-07-03
as burst noise in the ocw-connect-telemetry-events table)."""
monkeypatch.setenv("COWORKER_STATE_DIR", str(tmp_path / "coworker-state"))
# Universal scratch provisions a per-session dir for EVERY session — without this,
# tests would mkdir under the developer's real ~/OpenWorker.
monkeypatch.setenv("COWORKER_SCRATCH_BASE", str(tmp_path / "coworker-scratch"))
monkeypatch.delenv("COWORKER_API_TOKEN", raising=False)
@pytest_asyncio.fixture
async def fake_slack(monkeypatch):
"""A running FakeSlack control object; `SLACK_API_URL` is set to it for the test's duration."""
fake = FakeSlack()
await fake.start()
monkeypatch.setenv("SLACK_API_URL", fake.api_url)
try:
yield fake
finally:
await fake.stop()