aa5d5eeaf5
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 18s
CI / security (pull_request) Successful in 36s
CI / typecheck (pull_request) Successful in 38s
CI / unit_tests (pull_request) Successful in 2m42s
CI / integration_tests (pull_request) Successful in 3m13s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 6m15s
CI / benchmark-regression (pull_request) Successful in 34m51s
Implement TDD bug-capture tests for bug #570 where `agents session create` fails because `_get_session_service()` calls `container.db()` which does not exist on the DI Container class (AttributeError). Same root cause as bug #554. Behave BDD scenarios tagged @tdd_bug @tdd_bug_570 @tdd_expected_fail exercise the real DI path (no mocks). Includes Robot Framework integration smoke tests with self-inverting helper and ASV benchmark baseline. ISSUES CLOSED: #631
119 lines
3.6 KiB
Python
119 lines
3.6 KiB
Python
"""Helper script for tdd_session_create_di.robot smoke tests.
|
|
|
|
Each subcommand exercises the real DI path (no mocks) to reproduce bug #570.
|
|
The helper reports the **real** outcome: it exits 0 and prints the sentinel
|
|
when the operation succeeds (bug is fixed), and exits 1 when the bug is
|
|
still present. The ``tdd_expected_fail_listener`` on the Robot side handles
|
|
pass/fail inversion while the bug remains open.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from collections.abc import Callable
|
|
from pathlib import Path
|
|
|
|
# Ensure local source tree AND robot/ directory are importable.
|
|
_ROOT = Path(__file__).resolve().parents[1]
|
|
_SRC = str(_ROOT / "src")
|
|
_ROBOT = str(_ROOT / "robot")
|
|
for _p in (_SRC, _ROBOT):
|
|
if _p not in sys.path:
|
|
sys.path.insert(0, _p)
|
|
|
|
from helper_tdd_session_di_common import runner, setup_real_di, teardown # noqa: E402
|
|
|
|
from cleveragents.cli.commands.session import app as session_app # noqa: E402
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Subcommands
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
def create_di_error() -> None:
|
|
"""Invoke ``session create`` through the real DI path.
|
|
|
|
Exits 0 with sentinel when the command succeeds (bug fixed).
|
|
Exits 1 when the command fails (bug still present).
|
|
"""
|
|
db_path = setup_real_di()
|
|
try:
|
|
result = runner.invoke(session_app, ["create"])
|
|
if result.exit_code == 0:
|
|
print("tdd-session-create-di-error-ok")
|
|
else:
|
|
print(
|
|
f"session create failed with exit code {result.exit_code}",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(1)
|
|
finally:
|
|
teardown(db_path)
|
|
|
|
|
|
def create_actor() -> None:
|
|
"""Invoke ``session create --actor`` through the real DI path.
|
|
|
|
Exits 0 with sentinel when the command succeeds (bug fixed).
|
|
Exits 1 when the command fails (bug still present).
|
|
"""
|
|
db_path = setup_real_di()
|
|
try:
|
|
result = runner.invoke(
|
|
session_app,
|
|
["create", "--actor", "openai/gpt-4"],
|
|
)
|
|
if result.exit_code == 0:
|
|
print("tdd-session-create-actor-ok")
|
|
else:
|
|
print(
|
|
f"session create --actor failed with exit code {result.exit_code}",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(1)
|
|
finally:
|
|
teardown(db_path)
|
|
|
|
|
|
def create_json() -> None:
|
|
"""Invoke ``session create --format json`` through the real DI path.
|
|
|
|
Exits 0 with sentinel when the command succeeds (bug fixed).
|
|
Exits 1 when the command fails (bug still present).
|
|
"""
|
|
db_path = setup_real_di()
|
|
try:
|
|
result = runner.invoke(session_app, ["create", "--format", "json"])
|
|
if result.exit_code == 0:
|
|
print("tdd-session-create-json-ok")
|
|
else:
|
|
print(
|
|
"session create --format json failed "
|
|
f"with exit code {result.exit_code}",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(1)
|
|
finally:
|
|
teardown(db_path)
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Dispatcher
|
|
# ---------------------------------------------------------------------------
|
|
|
|
_COMMANDS: dict[str, Callable[[], None]] = {
|
|
"create-di-error": create_di_error,
|
|
"create-actor": create_actor,
|
|
"create-json": create_json,
|
|
}
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2 or sys.argv[1] not in _COMMANDS:
|
|
print(
|
|
f"Usage: {sys.argv[0]} <{'|'.join(_COMMANDS)}>",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(1)
|
|
cmd = _COMMANDS[sys.argv[1]]
|
|
cmd()
|