test(tui_gateway): pin materialized-row profile stamp against the #99222 contract
The fixture's _find_live_session_by_key/_child_run_active stubs predate the profile_home parameter; the profile_name assertion compared against a bare create_session (NULL) instead of the production stamp (profile_name_for_home(...) or _current_profile_name()) that _ensure_session_db_row applies on first-prompt persistence — the exact contract materialization must match. Co-authored-by: ruangraung <github@nadyahermes.anonaddy.com> Co-authored-by: Brooklyn Nicholson <brooklyn.bb.nicholson@gmail.com>
This commit is contained in:
committed by
brooklyn!
parent
c48e05a9d0
commit
7b384285fa
@@ -33,13 +33,13 @@ def real_db(monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(server, "_get_db", lambda: db)
|
||||
monkeypatch.setattr(server, "_resolve_model", lambda: "test-model")
|
||||
monkeypatch.setattr(server, "_enable_gateway_prompts", lambda: None)
|
||||
monkeypatch.setattr(server, "_find_live_session_by_key", lambda _key: None)
|
||||
monkeypatch.setattr(server, "_find_live_session_by_key", lambda _key, _home=None: None)
|
||||
monkeypatch.setattr(server, "_schedule_agent_build", lambda *a, **k: None)
|
||||
monkeypatch.setattr(server, "_schedule_session_cap_enforcement", lambda *a, **k: None)
|
||||
monkeypatch.setattr(server, "_maybe_schedule_auto_continue", lambda *a, **k: None)
|
||||
monkeypatch.setattr(server, "_default_session_cwd", lambda *a, **k: str(tmp_path))
|
||||
monkeypatch.setattr(server, "_profile_configured_cwd", lambda _home: str(tmp_path))
|
||||
monkeypatch.setattr(server, "_child_run_active", lambda _key: False)
|
||||
monkeypatch.setattr(server, "_child_run_active", lambda _key, _home=None: False)
|
||||
known = set(server._sessions)
|
||||
yield db
|
||||
with server._sessions_lock:
|
||||
@@ -67,7 +67,12 @@ def test_resume_materializes_row_for_minted_key(real_db):
|
||||
assert row is not None, "resume must materialize the DB row"
|
||||
assert row["source"] == "tui"
|
||||
assert row["model"] == "test-model"
|
||||
assert row.get("profile_name") is None # launch/default profile
|
||||
# Materialization stamps the launch profile explicitly (the #99222 contract
|
||||
# _ensure_session_db_row applies on first-prompt persistence: profile_name_for_home
|
||||
# or _current_profile_name, never NULL). A bare create_session leaves NULL, so the
|
||||
# oracle is the production expression itself, not a bare insert.
|
||||
assert row.get("profile_name") == (
|
||||
server.profile_name_for_home(None) or server._current_profile_name())
|
||||
|
||||
|
||||
def test_resume_existing_row_unaffected(real_db):
|
||||
|
||||
Reference in New Issue
Block a user