test(integration): Verify history persistence and AI context inclusion

This commit is contained in:
2026-02-24 22:06:33 -05:00
parent 7bed5efe61
commit 754fbe5c30
2 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import pytest
import tomli_w
from pathlib import Path
import aggregate
import project_manager
def test_aggregate_includes_segregated_history(tmp_path):
proj_path = tmp_path / "manual_slop.toml"
hist_path = tmp_path / "manual_slop_history.toml"
# Setup segregated project
proj_data = project_manager.default_project("test-aggregate")
proj_data["discussion"]["discussions"]["main"]["history"] = ["@2026-02-24T14:00:00\nUser:\nShow me history"]
# Save (will segregate)
project_manager.save_project(proj_data, proj_path)
# Run aggregate
loaded_proj = project_manager.load_project(proj_path)
config = project_manager.flat_config(loaded_proj)
markdown, output_file, file_items = aggregate.run(config)
assert "## Discussion History" in markdown
assert "Show me history" in markdown

View File

@@ -0,0 +1,44 @@
import pytest
import tomli_w
import tomllib
from pathlib import Path
from project_manager import load_project, save_project, default_project, entry_to_str
def test_history_persistence_across_turns(tmp_path):
proj_path = tmp_path / "manual_slop.toml"
hist_path = tmp_path / "manual_slop_history.toml"
# 1. Start project
proj = default_project("test-persistence")
save_project(proj, proj_path)
# 2. Add a turn
proj = load_project(proj_path)
entry1 = {"role": "User", "content": "Hello", "ts": "2026-02-24T13:00:00"}
proj["discussion"]["discussions"]["main"]["history"].append(entry_to_str(entry1))
save_project(proj, proj_path)
# Verify separation
with open(proj_path, "rb") as f:
p_disk = tomllib.load(f)
assert "discussion" not in p_disk
with open(hist_path, "rb") as f:
h_disk = tomllib.load(f)
assert h_disk["discussions"]["main"]["history"] == ["@2026-02-24T13:00:00\nUser:\nHello"]
# 3. Add another turn
proj = load_project(proj_path)
entry2 = {"role": "AI", "content": "Hi there!", "ts": "2026-02-24T13:01:00"}
proj["discussion"]["discussions"]["main"]["history"].append(entry_to_str(entry2))
save_project(proj, proj_path)
# Verify persistence
with open(hist_path, "rb") as f:
h_disk = tomllib.load(f)
assert len(h_disk["discussions"]["main"]["history"]) == 2
assert h_disk["discussions"]["main"]["history"][1] == "@2026-02-24T13:01:00\nAI:\nHi there!"
# 4. Reload and check
proj_final = load_project(proj_path)
assert len(proj_final["discussion"]["discussions"]["main"]["history"]) == 2