| Layer | Command | Dependencies | Notes |
|---|---|---|---|
| Unit | pytest -q or pytest -q -m "not integration" |
conftest placeholders | Default; no real API calls |
| Integration | pytest tests/test_agent_sdk.py -m integration -v -s |
ANTHROPIC_API_KEY (real) |
Real Agent SDK; validates API and conversation records |
Unit tests use placeholders in tests/conftest.py to satisfy app/core/config import-time checks. No real API keys needed.
- Run
pytest -qdirectly - If
.envexists, conftest loads it to override placeholders (for integration tests)
Integration tests call the real Claude Agent SDK. Configure:
# In .env (do not commit)
ANTHROPIC_API_KEY=sk-...
# Optional for Wan26Media MCP integration test
DASHSCOPE_API_KEY=sk-...
# Opt-in switch for Wan26Media forced-call integration test
RUN_WAN26_MCP_TEST=1Optional: SANDBOX_TEST_MODEL=claude-haiku-4-5-20251001 for cheaper model.
Note:
ANTHROPIC_API_KEY=testor empty triggers test skip; not a pass.
Acceptance requires real.envand real call results.
# Unit tests (recommended)
pytest -q -m "not integration"
# All unit tests
pytest -q
# AgentSDK integration (requires real .env)
pytest tests/test_agent_sdk.py -m integration -v -s
# One-shot local CI (unit + AgentSDK integration)
bash scripts/ci_local.sh| File | Type | Description |
|---|---|---|
test_api.py |
Unit | API endpoints (topics/posts validation and persistence) |
test_agent_sdk.py |
Unit + Integration | Agent SDK: unit (mock, CI) + integration (real API, requires ANTHROPIC_API_KEY) |
When changing topic experts or digital-twin import logic, verify these API expectations:
publicdigital twin import ->GET /topics/{topic_id}/experts/{expert_name}/contentreturns fullrole_contentwithmasked=falseprivatedigital twin import -> same endpoint returns masked content withmasked=true- Existing expert create/edit/delete flows remain compatible
- Run
test_agent_sdk.py -m integrationwith real.env(no placeholders) POST /topics/{topic_id}/posts/mentionreturns202- Poll
GET /topics/{topic_id}/posts/mention/{reply_post_id}untilcompleted GET /topics/{topic_id}/postsshows user post and expert reply- Reply record is queryable via API/database with
status=completed - Discussion artifacts still appear under
workspace/topics/{topic_id}/shared/ - For
test_discussion_mcp_wan26media_forced_call_integration, ensureRUN_WAN26_MCP_TEST=1andDASHSCOPE_API_KEYare set
- PR must pass:
pytest -q -m "not integration" - Integration: Run as cron or manual; requires
ANTHROPIC_API_KEYsecret
To verify API calls against Docker deployment:
# Ensure Docker daemon is running, then:
./scripts/test_docker_api.shThe script builds the image, starts the container, runs health/topics/experts/posts checks, then stops. Uses existing .env or creates a minimal one if missing (placeholder keys; no real AI calls).
All Agent SDK tests live in one file tests/test_agent_sdk.py:
- Unit (CI, no API key):
_extract_reply_body,run_expert_replymocked,run_discussionmocked, mention API mocked - Integration (manual/cron, needs ANTHROPIC_API_KEY): real mention and discussion flows; skip if no key
Contributors: add unit tests for new Agent SDK paths (CI coverage); add integration tests for real API validation.
For mock strategies and best practices, see Agent SDK Testing Practices.
- GitHub Actions:
.github/workflows/tests-ci.yml - Triggers:
push,pull_request,workflow_dispatch - Detect changes job runs first (git diff); unit jobs skip when no relevant changes:
- Unit (API): runs when
app/api/**,app/models/**,app/core/**,main.py,tests/test_api.py,tests/conftest.pychange - Unit (Agent SDK): runs when
app/agent/**,app/prompts/**,skills/**(includingskills/scenarios/**),tests/test_agent_sdk.py,tests/conftest.pychange - Integration (Agent SDK): depends on Unit (Agent SDK); also skipped when no API key
- Unit (API): runs when
workflow_dispatch: always runs all tests (no diff)- To run integration on GitHub: add
ANTHROPIC_API_KEYas a repository secret - Full local CI (with AgentSDK):
bash scripts/ci_local.sh