Skip to content

Commit d7c0e26

Browse files
paddymulclaude
andcommitted
test(#133): update detail/notebook stubs for the lazy-session decoupling
Two existing tests encoded pre-#133 behavior — that api_entry_detail carries a buckaroo_session, and that get_session returns a bare {ws_url}. Detail is now metadata-only and get_session calls load_session, so update the BuckarooManager stubs to implement load_session and assert the new decoupled contract (detail session is null; the grid loads via /api/session with a typed status). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3954283 commit d7c0e26

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

tests/test_buckaroo.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,21 +733,30 @@ def ws_base_url(self) -> str:
733733
def ensure_session(self, content_hash: str, project: str, column_config_overrides=None) -> str | None:
734734
return self.session
735735

736+
def load_session(self, content_hash: str, project: str, column_config_overrides=None) -> dict:
737+
return {"status": "ok", "session_id": self.session, "detail": ""}
736738

737-
def test_entry_detail_embeds_react_widget_when_buckaroo_present(project: str, orders_parquet: Path):
738-
"""API returns buckaroo_session and buckaroo_ws_base when Buckaroo is running."""
739+
740+
def test_entry_detail_decoupled_grid_session_via_session_endpoint(project: str, orders_parquet: Path):
741+
"""The detail payload is metadata-only; the grid session loads lazily via
742+
/api/session so the detail request never blocks on Buckaroo (#133)."""
739743
from tallyman_companion import create_app
740744

741745
res = build_and_persist(project, _code(project))
742746
bk: Any = _StubBuckaroo(session="abc123", port=8700)
743747
app = create_app(project, buckaroo=bk)
744748
c = TestClient(app)
745-
r = c.get(f"/{project}/api/entry/{res.content_hash}")
746-
assert r.status_code == 200
747-
body = r.json()
748-
assert body["buckaroo_session"] == "abc123"
749+
750+
# Detail no longer carries a session — it's decoupled.
751+
body = c.get(f"/{project}/api/entry/{res.content_hash}").json()
752+
assert body["buckaroo_session"] is None
749753
assert body["buckaroo_ws_base"] == "ws://127.0.0.1:8700"
750754

755+
# The session endpoint provides the widget on demand, with a typed status.
756+
sr = c.get(f"/{project}/api/session/{res.content_hash}").json()
757+
assert sr["status"] == "ok"
758+
assert sr["ws_url"] == "ws://127.0.0.1:8700/ws/abc123"
759+
751760

752761
def test_entry_detail_falls_back_when_session_unavailable(project: str, orders_parquet: Path):
753762
"""When ensure_session returns None, API returns null for buckaroo fields."""

tests/test_notebook.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ def ws_base_url(self):
385385
def ensure_session(self, content_hash, project):
386386
return f"sess-{content_hash[:6]}"
387387

388+
def load_session(self, content_hash, project, column_config_overrides=None):
389+
return {"status": "ok", "session_id": f"sess-{content_hash[:6]}", "detail": ""}
390+
388391
app = create_app(project, buckaroo=_StubBuckaroo()) # type: ignore[arg-type]
389392
c = TestClient(app)
390393
r = c.get(f"/{project}/api/notebook_full")

0 commit comments

Comments
 (0)