Files
codex-app-server/cloud/tests/test_longfunc_inventory.py
T
host e00c255011 code-to10 v6 A13: 17-method long-function inventory incl _full_auto_execute plus support domain boundary comments
(cherry picked from commit 908df30d1a3cf328ea05344f0660af9b77bf24a1)

Reconcile-port: handler_support.py kept at HEAD (189 lines; A13 domain comments describe source's 1616-line handler_support layout, which does not exist here — functions live in server.py). test_longfunc_inventory.py kept as-is for now; it pins source architecture and will be re-pinned for the unified line in a final commit (recorded).
2026-11-03 02:49:26 +00:00

82 lines
3.6 KiB
Python

"""A13: >100-line method inventory (17 items, checkable in code).
The split summary's section 4 listed 16 >100-line methods; the
missing 17th is ``FullAutoMixin._full_auto_execute``
(``cloud/handler_fullauto.py:182-304``, 123 lines). This test
pins the full 17-method list by AST over ``cloud/handler_*.py``
plus ``cloud/server.py`` -- no external summary document is the
source of truth, the code itself is.
Counting rule, stated because a naive AST count gives 18:
the 17 are class methods. The 18th >100-line definition,
``handler_support.migrate_tasks_table`` (module-level function,
not a mixin method), is asserted separately as the ONLY
module-level >100-line definition, so the 17/18 difference is
explained, not hidden. No method is split by this batch:
internal splitting stays at 0 items.
"""
import ast
import unittest
from pathlib import Path
EXPECTED_METHODS = {
("handler_admin.py", "AdminMixin._task_pr"),
("handler_admin.py", "AdminMixin._metrics"),
("handler_browser.py", "BrowserMixin._browser_stream"),
("handler_core.py", "TaskCoreMixin._create_task"),
("handler_core.py", "TaskCoreMixin._create_followup"),
("handler_fullauto.py", "FullAutoMixin._full_auto_execute"),
("handler_lifecycle.py", "TaskLifecycleMixin._task_thread_read"),
("handler_lifecycle.py", "TaskLifecycleMixin._deliver_to_thread"),
("handler_lifecycle.py", "TaskLifecycleMixin._task_wait"),
("handler_lifecycle.py", "TaskLifecycleMixin._merge_task"),
("handler_lifecycle.py", "TaskLifecycleMixin._loop_run"),
("handler_lifecycle.py", "TaskLifecycleMixin._release_task"),
("handler_lifecycle.py", "TaskLifecycleMixin._continue_task"),
("handler_webhook.py", "WebhookMixin._handle_github_webhook"),
("server.py", "CloudControlPlaneHandler._dispatch_task_route"),
("server.py", "CloudControlPlaneHandler._dispatch"),
("server.py", "CloudControlPlaneHandler._dispatch_project"),
}
class LongFuncInventoryTestCase(unittest.TestCase):
def test_seventeen_long_methods_including_full_auto_execute(self):
cloud_dir = Path(__file__).resolve().parents[1]
methods = set()
module_funcs = set()
for path in sorted(cloud_dir.glob("handler_*.py")) + [
cloud_dir / "server.py"]:
tree = ast.parse(path.read_text(encoding="utf-8"))
for node in tree.body:
if isinstance(node, ast.ClassDef):
for member in node.body:
if isinstance(member, (ast.FunctionDef,
ast.AsyncFunctionDef)):
lines = (member.end_lineno
- member.lineno + 1)
if lines > 100:
methods.add(
(path.name,
"%s.%s" % (node.name, member.name)))
elif isinstance(node, (ast.FunctionDef,
ast.AsyncFunctionDef)):
lines = node.end_lineno - node.lineno + 1
if lines > 100:
module_funcs.add((path.name, node.name))
self.assertEqual(len(EXPECTED_METHODS), 17)
self.assertIn(
("handler_fullauto.py", "FullAutoMixin._full_auto_execute"),
EXPECTED_METHODS)
self.assertEqual(methods, EXPECTED_METHODS)
# The single non-method >100-line definition, documented
# rather than silently dropped from the count.
self.assertEqual(
module_funcs,
{("handler_support.py", "migrate_tasks_table")})
if __name__ == "__main__":
unittest.main()