fix: address pre-merge review findings — stale identity strings, pyright error, fragile test path, formatting, README accuracy
Required fixes:
- main.py: update module docstring, startup comment, and FastAPI title from
'tmux-web coordinator' / 'coordinator service' → 'muxplex' (4 locations)
- test_api.py: replace hasattr/BaseRoute pattern with isinstance(r, (APIRoute,
APIWebSocketRoute)) to satisfy pyright (union-attr error eliminated)
Recommendations applied:
- test_api.py + test_cli.py: auto-formatted with ruff (blank-line normalisation)
- test_cli.py: replace exec(Path('muxplex/__main__.py').read_text()) with
importlib.util.find_spec() to obtain the absolute path — no longer assumes
pytest is invoked from a specific working directory
- README.md: fix architecture table — WebSocket proxy moved from ttyd.py
description to main.py; ttyd.py now correctly described as lifecycle only
All 178 tests pass; python_check clean (0 errors, 0 warnings).
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Tests for coordinator/main.py — FastAPI skeleton, lifespan, /health endpoint.
|
||||
Tests for muxplex/main.py — FastAPI skeleton, lifespan, /health endpoint.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
@@ -149,9 +149,7 @@ def test_patch_state_ignores_unknown_fields(client):
|
||||
def test_get_sessions_returns_list(client, monkeypatch):
|
||||
"""GET /api/sessions must return a JSON list."""
|
||||
monkeypatch.setattr("muxplex.main.get_session_list", lambda: ["alpha"])
|
||||
monkeypatch.setattr(
|
||||
"muxplex.main.get_snapshots", lambda: {"alpha": "some text"}
|
||||
)
|
||||
monkeypatch.setattr("muxplex.main.get_snapshots", lambda: {"alpha": "some text"})
|
||||
|
||||
response = client.get("/api/sessions")
|
||||
assert response.status_code == 200
|
||||
@@ -210,9 +208,7 @@ def test_get_sessions_includes_bell_state(client, monkeypatch):
|
||||
from muxplex.state import save_state
|
||||
|
||||
monkeypatch.setattr("muxplex.main.get_session_list", lambda: ["delta"])
|
||||
monkeypatch.setattr(
|
||||
"muxplex.main.get_snapshots", lambda: {"delta": "pane text"}
|
||||
)
|
||||
monkeypatch.setattr("muxplex.main.get_snapshots", lambda: {"delta": "pane text"})
|
||||
save_state(
|
||||
{
|
||||
"active_session": None,
|
||||
@@ -647,9 +643,13 @@ def test_api_routes_not_shadowed(client):
|
||||
|
||||
def test_terminal_ws_route_exists():
|
||||
"""The app must have a WebSocket route registered at /terminal/ws."""
|
||||
from fastapi.routing import APIRoute, APIWebSocketRoute
|
||||
|
||||
from muxplex.main import app
|
||||
|
||||
ws_routes = [
|
||||
r for r in app.routes
|
||||
if hasattr(r, "path") and r.path == "/terminal/ws"
|
||||
r
|
||||
for r in app.routes
|
||||
if isinstance(r, (APIRoute, APIWebSocketRoute)) and r.path == "/terminal/ws"
|
||||
]
|
||||
assert len(ws_routes) == 1, "Expected exactly one /terminal/ws route"
|
||||
|
||||
Reference in New Issue
Block a user