forked from cleveragents/cleveragents-core
aa5d5eeaf5
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
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Shared helpers for TDD session DI ASV benchmarks.
|
|
|
|
Extracted from ``tdd_session_create_di_bench.py`` and
|
|
``tdd_session_list_di_bench.py`` to eliminate duplication (review finding F9).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
# Ensure the local *source* tree is importable even when ASV has an
|
|
# older build of the package installed. This is a permanent mutation of
|
|
# ``sys.path`` — acceptable because ASV runs each benchmark suite in its
|
|
# own isolated process.
|
|
_SRC = str(Path(__file__).resolve().parents[1] / "src")
|
|
if _SRC not in sys.path:
|
|
sys.path.insert(0, _SRC)
|
|
|
|
from typer.testing import CliRunner # noqa: E402
|
|
from ulid import ULID # noqa: E402
|
|
|
|
from cleveragents.domain.models.core.session import ( # noqa: E402
|
|
Session,
|
|
SessionTokenUsage,
|
|
)
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
def mock_session(
|
|
session_id: str | None = None,
|
|
actor_name: str | None = None,
|
|
) -> Session:
|
|
"""Create a ``Session`` instance with sensible defaults for benchmarks."""
|
|
return Session(
|
|
session_id=session_id or str(ULID()),
|
|
actor_name=actor_name,
|
|
namespace="local",
|
|
messages=[],
|
|
token_usage=SessionTokenUsage(),
|
|
created_at=datetime.now(),
|
|
updated_at=datetime.now(),
|
|
)
|