test: repair full suite — hang fix, stale-test updates, patch hygiene, timeout backstop

Suite went from 27 failures plus one permanent hang (never finished) to
1846 passed / 0 failed in ~85s, including under FORCE_COLOR.

- office_shutdown_lifecycle: construct WSHandler via the real __init__
  (helper) instead of hand-copied __new__ stubs that drift from the
  constructor (#11 added _runtime_status_sync_task and the stubs hung);
  the formerly-hanging wait now has a 5s wait_for.
- import-time patch hygiene: company_recruiter / company_reorg /
  engine_session_defaults replaced module-level permanent
  tempfile.TemporaryDirectory monkeypatching with paired
  setUpModule/tearDownModule, fixing order-dependent sqlite failures in
  transcript_pagination during full runs.
- stale tests updated to current product semantics: resume stubs use
  status="done" (failed is deliberately non-resumable), fix4 asserts the
  native review contract through build_company_work_item_contract,
  delivery fixture carries user_visible/feedback_scope=final, ownership
  doc names progress_log, session compression calls
  maybe_compact_session(force=True) explicitly, hard delete removes the
  work item row, parallel-isolation asserts delegate rebind and stubs
  _get_project_delegate, role update goes through OrgService on an
  editable custom org (plus read-only rejection case), collab_rpc patches
  the single os.name decision point instead of poisoning pathlib, codex
  no-pty builds inside the patch, identity-guard false positives reworded.
- cli_board actions rewritten against the real OfficeServiceFactory seam
  with a tempdir OPC_HOME (old direct-engine stubs were never consulted
  and the tests wrote into the real OPC home).
- cli_app assertions strip ANSI via _plain_output so a color-forcing
  shell (FORCE_COLOR) cannot break plain-text expectations.
- deleted never-runnable test_org_concurrency (pytest.mark.asyncio
  without the plugin, stdlib-only assertions) and three dead skipped
  filesystem-handoff tests.
- pyproject: dev extra (pytest, pytest-timeout) and a 300s per-test
  timeout backstop so a wedged test fails instead of stalling the suite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
LZH-YS1998
2026-07-26 22:14:47 +08:00
parent 9977c3be57
commit 76c530a9e5
20 changed files with 424 additions and 447 deletions
+3 -2
View File
@@ -377,7 +377,8 @@ async def test_ui_project_switch_uses_delegate_without_cancelling_background_tas
await asyncio.sleep(0)
root._get_project_delegate.assert_awaited_once_with("project-b")
assert handler.engine is root
# Project switch deliberately rebinds the handler to the delegate.
assert handler.engine is delegate
assert handler._client_project_ids[ws] == "project-b"
assert handler._client_switch_seq[ws] == "seq-1"
sent_types = [call.args[0]["type"] for call in ws.send_json.await_args_list]
@@ -748,6 +749,7 @@ async def test_kanban_create_task_routes_by_request_project_id() -> None:
engine_b = _ui_engine("project-b", _MemoryStore([]))
chat_store = _ui_chat_store()
handler = WSHandler(engine_a, MagicMock(), chat_store, _ui_event_adapter())
engine_a._get_project_delegate = AsyncMock(return_value=engine_b)
handler._engine_for_project = AsyncMock(
side_effect=lambda project_id: engine_b if project_id == "project-b" else engine_a,
)
@@ -877,7 +879,6 @@ def test_explicit_agent_overrides_company_role_agent_defaults() -> None:
runtime_topology=topology,
decision=decision,
project_id="proj",
role_agent_overrides={"ceo": "codex"},
)
seat = enriched["seats"][0]