Make .env optional in tests and prevent endpoint resolver stubs from leaking into model route tests.
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
"""Tests for context_compactor.py — constants and prompt templates.
|
|
Uses mock imports to avoid loading the full app stack."""
|
|
|
|
import sys
|
|
from unittest.mock import MagicMock
|
|
|
|
# Mock heavy dependencies before importing
|
|
for mod in [
|
|
'sqlalchemy', 'sqlalchemy.orm', 'sqlalchemy.ext', 'sqlalchemy.ext.declarative',
|
|
'sqlalchemy.ext.hybrid', 'sqlalchemy.sql', 'sqlalchemy.sql.expression',
|
|
'src.database',
|
|
'core.models', 'core.database',
|
|
]:
|
|
if mod not in sys.modules:
|
|
sys.modules[mod] = MagicMock()
|
|
|
|
from src.context_compactor import (
|
|
COMPACT_THRESHOLD,
|
|
SELF_SUMMARY_SYSTEM_PROMPT,
|
|
SUMMARY_MAX_TOKENS,
|
|
)
|
|
|
|
|
|
class TestCompactThreshold:
|
|
def test_value(self):
|
|
assert COMPACT_THRESHOLD == 0.85
|
|
|
|
def test_summary_max_tokens(self):
|
|
assert SUMMARY_MAX_TOKENS == 1024
|
|
|
|
|
|
class TestSelfSummaryPrompt:
|
|
def test_contains_goal_section(self):
|
|
assert "### User Goal" in SELF_SUMMARY_SYSTEM_PROMPT
|
|
|
|
def test_contains_what_was_done_section(self):
|
|
assert "### What Was Done" in SELF_SUMMARY_SYSTEM_PROMPT
|
|
|
|
def test_contains_current_state_section(self):
|
|
assert "### Current State" in SELF_SUMMARY_SYSTEM_PROMPT
|
|
|
|
def test_contains_pending_section(self):
|
|
assert "### Pending / Next Steps" in SELF_SUMMARY_SYSTEM_PROMPT
|
|
|
|
def test_contains_key_context_section(self):
|
|
assert "### Key Context" in SELF_SUMMARY_SYSTEM_PROMPT
|
|
|
|
def test_count_placeholder(self):
|
|
assert "{count}" in SELF_SUMMARY_SYSTEM_PROMPT
|
|
|
|
def test_n_placeholder(self):
|
|
assert "{n}" in SELF_SUMMARY_SYSTEM_PROMPT
|
|
|
|
def test_mentions_compactions(self):
|
|
assert "Compactions so far" in SELF_SUMMARY_SYSTEM_PROMPT
|