bacddc8549
TIER-2 READ AGENTS.md conductor/workflow.md conductor/edit_workflow.md conductor/tier2/githooks/forbidden-files.txt conductor/tracks/tier2_leak_prevention_20260620/spec.md conductor/code_styleguides/data_oriented_design.md conductor/code_styleguides/error_handling.md conductor/code_styleguides/type_aliases.md before Phase 0 Tasks 0.1, 0.2, 0.4. Phase 0 of metadata_promotion_20260624. 11 NEW per-aggregate dataclasses added to src/type_aliases.py (CommsLogEntry, HistoryMessage, FileItem, ToolDefinition, SessionInsights, DiscussionSettings, CustomSlice, MMAUsageStats, ProviderPayload, UIPanelConfig, PathInfo) + RAGChunk added to src/rag_engine.py. Metadata: TypeAlias = dict[str, Any] preserved unchanged as the catch-all for collapsed codepaths. Each dataclass has paired to_dict()/from_dict() methods. 11 regression-guard test files created with 5-7 tests each (~70 tests total). All tests PASS. The existing tests/test_type_aliases.py was updated to reflect the NEW design (CommsLogEntry etc. are now classes, not aliases to Metadata). Conventions: 1-space indentation, CRLF preserved, no comments.
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
"""Tests for SessionInsights in src/type_aliases.py
|
|
|
|
Per-aggregate dataclass regression-guard for the metadata_promotion_20260624 track.
|
|
|
|
CONVENTION: 1-space indentation. NO COMMENTS.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import FrozenInstanceError
|
|
|
|
import pytest
|
|
|
|
from src.type_aliases import SessionInsights
|
|
|
|
|
|
def test_constructor_with_kwargs() -> None:
|
|
si = SessionInsights(total_tokens=1000, call_count=5, burn_rate=2.5)
|
|
assert si.total_tokens == 1000
|
|
assert si.call_count == 5
|
|
assert si.burn_rate == 2.5
|
|
|
|
|
|
def test_field_access() -> None:
|
|
si = SessionInsights(session_cost=0.42, completed_tickets=3, efficiency=0.85)
|
|
assert si.session_cost == 0.42
|
|
assert si.completed_tickets == 3
|
|
assert si.efficiency == 0.85
|
|
|
|
|
|
def test_frozen_raises_on_mutation() -> None:
|
|
si = SessionInsights()
|
|
with pytest.raises(FrozenInstanceError):
|
|
si.total_tokens = 100
|
|
|
|
|
|
def test_to_dict_roundtrip() -> None:
|
|
si = SessionInsights(total_tokens=100, call_count=2, burn_rate=1.5, session_cost=0.5, completed_tickets=3, efficiency=0.9)
|
|
d = si.to_dict()
|
|
assert d["total_tokens"] == 100
|
|
assert d["call_count"] == 2
|
|
assert d["efficiency"] == 0.9
|
|
|
|
|
|
def test_default_values() -> None:
|
|
si = SessionInsights()
|
|
assert si.total_tokens == 0
|
|
assert si.call_count == 0
|
|
assert si.burn_rate == 0.0
|
|
assert si.session_cost == 0.0
|
|
assert si.completed_tickets == 0
|
|
assert si.efficiency == 0.0
|
|
|
|
|
|
def test_hashability() -> None:
|
|
si = SessionInsights(total_tokens=10)
|
|
assert hash(si) is not None |