mirror of
https://github.com/andrewyng/openworker.git
synced 2026-09-03 13:00:37 +00:00
Imported from andrewyng/aisuite@1b4bbf303e (contents of its platform/ directory, hoisted to the repo root). Development history prior to this commit lives in that repository. Co-authored-by: Devika <devikaverma11@gmail.com>
36 lines
1.3 KiB
Python
36 lines
1.3 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"))
|
|
|
|
|
|
@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()
|