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:
+21
-8
@@ -4,6 +4,7 @@ import asyncio
|
||||
import importlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sqlite3
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -58,6 +59,17 @@ from opc.plugins.office_ui.services.project import ProjectService
|
||||
from opc.plugins.office_ui.services.session import SessionService
|
||||
from opc.plugins.office_ui.services.work_item import WorkItemService
|
||||
|
||||
_ANSI_ESCAPE_RE = re.compile(r"\x1b\[[0-9;]*[A-Za-z]")
|
||||
|
||||
|
||||
def _plain_output(text: str) -> str:
|
||||
"""CLI output with ANSI styling stripped.
|
||||
|
||||
Keeps plain-text assertions stable when the invoking shell forces
|
||||
color (e.g. FORCE_COLOR) onto rich/typer output.
|
||||
"""
|
||||
return _ANSI_ESCAPE_RE.sub("", text)
|
||||
|
||||
|
||||
class CliEscalationFormattingTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
@@ -305,7 +317,7 @@ class CliInitProjectTests(unittest.TestCase):
|
||||
result = runner.invoke(app, ["init", "dupe"])
|
||||
|
||||
self.assertNotEqual(result.exit_code, 0)
|
||||
self.assertIn("Project 'dupe' already exists", result.output)
|
||||
self.assertIn("Project 'dupe' already exists", _plain_output(result.output))
|
||||
self.assertFalse((opc_home / "projects" / "dupe").exists())
|
||||
|
||||
def test_init_existing_config_cancel_preserves_config_and_does_not_create_project(self) -> None:
|
||||
@@ -3119,7 +3131,7 @@ class CliChannelCommandTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
mock_kill.assert_called_once()
|
||||
self.assertIn("PID 4321", result.stdout)
|
||||
self.assertIn("PID 4321", _plain_output(result.stdout))
|
||||
|
||||
def test_channels_status_reports_runtime_and_capabilities(self) -> None:
|
||||
config = OPCConfig()
|
||||
@@ -3165,9 +3177,10 @@ class CliAutomationCommandTests(unittest.TestCase):
|
||||
result = self.runner.invoke(app, ["exec", "--help"])
|
||||
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
self.assertIn("--session-id", result.output)
|
||||
self.assertIn("--resume", result.output)
|
||||
self.assertIn("--stream-json", result.output)
|
||||
help_text = _plain_output(result.output)
|
||||
self.assertIn("--session-id", help_text)
|
||||
self.assertIn("--resume", help_text)
|
||||
self.assertIn("--stream-json", help_text)
|
||||
|
||||
def test_exec_rejects_json_and_stream_json_together(self) -> None:
|
||||
result = self.runner.invoke(app, ["exec", "hello", "--json", "--stream-json"])
|
||||
@@ -3207,9 +3220,9 @@ class CliTalentCommandTests(unittest.TestCase):
|
||||
self.assertEqual(import_result.exit_code, 0)
|
||||
self.assertEqual(hire_result.exit_code, 0)
|
||||
self.assertEqual(list_result.exit_code, 0)
|
||||
self.assertIn("Imported 1 talent templates", import_result.stdout)
|
||||
self.assertIn("Bea Backend", hire_result.stdout)
|
||||
self.assertIn("engineering-backend-architect", list_result.stdout)
|
||||
self.assertIn("Imported 1 talent templates", _plain_output(import_result.stdout))
|
||||
self.assertIn("Bea Backend", _plain_output(hire_result.stdout))
|
||||
self.assertIn("engineering-backend-architect", _plain_output(list_result.stdout))
|
||||
|
||||
config = OPCConfig.load(opc_home / "config")
|
||||
self.assertEqual(config.org.talent_templates, [])
|
||||
|
||||
Reference in New Issue
Block a user