Problem
`uv run pytest` in `backend/` reports 22 passing, 4 failing. All four failures need a live MCP server running at `http://localhost:3001/mcp\`:
- `tests/test_tools.py::test_place_order_returns_payment_challenge` — `run_tool("place_order", ...)` calls FastMCP client internally
- `tests/test_tools.py::test_x402_settle_returns_tx_hash` — same path via `place_order`
- `tests/test_tools.py::test_agent_emits_a2ui_then_end` — `GiftAgent.turn()` fetches MCP schemas at startup
- `tests/test_app.py::test_agent_uses_beta_client_with_mcp_servers` — see related issue (dead code)
Options (pick per-test)
- Mock the FastMCP client: `pytest.fixture` returning a stub `McpClient` that yields canned schemas / tool results. Most flexible.
- Mark `@pytest.mark.integration` + skip by default: run only when `MCP_URL` env is set + server reachable. Good for the agent-roundtrip ones.
- Start an MCP server in a `pytest.fixture(scope="session")`: launch `mcp/server.py` subprocess, tear down at session end. Most realistic but slowest.
Recommended split
- Tool-level tests (`place_order`, `x402_settle`) → mock the MCP client
- Agent-turn test → integration mark + skip unless server up
Caught by
PR #4 rebase validation — run_tool became async in PR #1 (FastMCP integration); the rebased state inherits the dependency without mocks.
Problem
`uv run pytest` in `backend/` reports 22 passing, 4 failing. All four failures need a live MCP server running at `http://localhost:3001/mcp\`:
Options (pick per-test)
Recommended split
Caught by
PR #4 rebase validation —
run_toolbecame async in PR #1 (FastMCP integration); the rebased state inherits the dependency without mocks.