Files
impactflow_discovery/tests/test_profile_history.py
T
Joel Salmon b9d7b0e22b Phase 5: iteration & polish (visualizations, goal history, smart tagging)
Final roadmap phase. No DB migration — it reads data already captured.

- Goal-evolution history: GET /discovery/profile/me/goal-history derives a
  per-goal timeline from the profile_revision snapshots (pure aggregator in
  app/services/profile_history.py).
- Smart tagging: POST /discovery/integration/suggest-foundation suggests which
  foundation a task builds toward + rationale/confidence (FoundationTagger,
  app/services/tagging.py). Suggestion only; the person confirms by posting the
  task mapping.
- Deeper goal-refinement: the reflect loop accepts an optional focus ("goals")
  that steers the coach toward sharpening goals — still mirror, not compass.
- Visualizations: visuals.html renders an Ikigai Venn and an Enneagram diagram
  (plain-language callouts, not the raw type number) plus the goal-evolution
  timeline; linked from profile.html.

Tests: 99 passing (added pure goal-history tests, goal-history + suggest
endpoint tests, reflect-focus passthrough; run in-container). README updated.

This completes the ImpactFlow Vision roadmap (Phases 1-5) on the Discovery side.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 21:37:33 -05:00

48 lines
1.6 KiB
Python

"""Unit tests for the pure goal-evolution aggregator."""
from datetime import datetime, timezone
from app.services.profile_history import goal_history
def _rev(short, long_, source, day):
return {
"fields": {"short_term_goals": short, "long_term_goals": long_},
"source": source,
"created_at": datetime(2026, 6, day, tzinfo=timezone.utc),
}
def test_collapses_consecutive_identical_values():
revs = [
_rev("a", "x", "extraction", 1),
_rev("a", "x", "manual_edit", 2), # no change -> skipped
_rev("b", "x", "reflection", 3), # short changed
]
h = goal_history(revs)
assert [e["value"] for e in h["short_term_goals"]] == ["a", "b"]
assert [e["value"] for e in h["long_term_goals"]] == ["x"]
assert h["short_term_goals"][1]["source"] == "reflection"
def test_each_field_tracked_independently():
revs = [
_rev("a", "x", "extraction", 1),
_rev("a", "y", "reflection", 2), # only long changed
]
h = goal_history(revs)
assert len(h["short_term_goals"]) == 1
assert [e["value"] for e in h["long_term_goals"]] == ["x", "y"]
def test_empty_revisions_yield_empty_timelines():
h = goal_history([])
assert h == {"short_term_goals": [], "long_term_goals": []}
def test_first_value_emitted_even_if_none():
revs = [_rev(None, None, "extraction", 1), _rev("a", None, "reflection", 2)]
h = goal_history(revs)
assert [e["value"] for e in h["short_term_goals"]] == [None, "a"]
# long stayed None throughout -> a single None entry
assert [e["value"] for e in h["long_term_goals"]] == [None]