Skip to content

fix(claude): repair the broken test file and add the endpoints it imports - #289

Open
fig-ai-agent[bot] wants to merge 1 commit into
mainfrom
fix/claude-endpoints-and-test
Open

fix(claude): repair the broken test file and add the endpoints it imports#289
fig-ai-agent[bot] wants to merge 1 commit into
mainfrom
fix/claude-endpoints-and-test

Conversation

@fig-ai-agent

@fig-ai-agent fig-ai-agent Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What this fixes

tests/test_claude_endpoints.py (added in #241, commit 3702790) is chat prose wrapped around a fenced code block, not Python. It fails to even parse:

SyntaxError: invalid character '→' (U+2192)

Because pytest imports every file under tests/, that one file broke collection for the whole directory — every valid test beside it was blocked. This PR repairs it and supplies the module it imports but that never existed.

New files

File Purpose
app/services/claude_client.py async Claude client over httpxstream_message() yields decoded SSE frames, send_message() returns the full body. No new SDK dependency.
app/api/v1/endpoints/claude.py POST /claude/chat/stream (SSE), POST /claude/chat/tools (tool-calling), GET /claude/status

Pre-existing breakage fixed (both blocked any import of app.services)

  1. app/services/__init__.py did from .users import UserServiceUserService does not exist in users.py (it defines UserRepo). A package __init__ runs before any submodule import, so this made app.services.* app.main-blocking. Now resolves lazily (PEP 562), so one broken downstream module can no longer take out the whole package.
  2. app/core/config.pySettings() raised on the repo's own .env: undeclared keys (WHATSAPP_*, BYTEPLUS_*, …) plus a required OAUTH_CLIENT_ID. Added extra = "ignore" and a default.

Verification

$ python -m pytest tests/test_claude_endpoints.py --noconftest -q
4 passed

Collection errors across tests/, vs. untouched origin/main:

errors collected
origin/main 10 28
this branch 5 38

No regressions — every remaining error is present on main unchanged (comm diff of the two error sets). Five fixed, ten new tests collected.

Two things worth your eye

  • app/.gitignore contains a bare service* rule that ignores anything under app/services/. The new client module would have been silently dropped, so it is force-added (git add -f). That rule looks like an accident — worth deleting separately.
  • Two assertions in the recovered test were wrong and I corrected them: lines == 'data: {...}' compared a list to a str (and would still be wrong even if the types matched), and tool_calls["name"] indexed a list. The endpoint also emitted data: "[DONE]" (JSON-quoted) instead of the bare SSE sentinel.

Not included on purpose: app/db/repositories.py is also broken (AsyncSession/Item undefined — 5 of the remaining collection errors). It is unrelated to this deliverable and belongs in its own PR.

…orts

tests/test_claude_endpoints.py was chat prose wrapped around a fenced code
block, so tests/ failed collection repo-wide with
'SyntaxError: invalid character (U+2192)'. Extracted the real code, fixed two
assertion bugs in it, and added the module it imports but that never existed.

New:
  - app/services/claude_client.py     httpx-based Claude client (stream + send)
  - app/api/v1/endpoints/claude.py    POST /claude/chat/stream, /claude/chat/tools, GET /claude/status

Fixed (pre-existing, both blocked any import of app.services):
  - app/services/__init__.py  imported UserService, which users.py never defined;
    now resolves lazily so one broken downstream module no longer takes out the
    whole package
  - app/core/config.py        Settings() raised on the repo's own .env (undeclared
    keys + required OAUTH_CLIENT_ID); extra=ignore and a default

Verified: 4/4 pass; tests/ collection errors 10 -> 5, no new ones.
The 5 remaining are pre-existing and unrelated.

Note: app/.gitignore's 'service*' rule would silently exclude the new client
module, so it is force-added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants