Files
FabledScribe/tests/test_journal_search.py
T
bvandeusen ce76a003f7 feat(journal): /api/journal/* routes blueprint + cosine helper unit tests
Endpoints:
- GET/PUT /api/journal/config — per-user journal config
- GET /api/journal/today — today's journal conversation, generates daily prep on demand
- GET /api/journal/day/<iso_date> — past day's journal
- GET /api/journal/days — list of dates with journal content
- POST /api/journal/trigger-prep — manual regeneration of prep
- GET /api/journal/moments — list/search moments with filters
- PATCH /api/journal/moments/<id> — edit content/tags/pinned + junctions
- DELETE /api/journal/moments/<id>

Blueprint registered in app.py.
tests/test_journal_search.py — cosine helper coverage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-25 22:40:56 -04:00

24 lines
575 B
Python

"""Unit tests for the cosine helper inside journal_search."""
import math
from fabledassistant.services.journal_search import _cosine
def test_cosine_identical_vectors():
v = [1.0, 2.0, 3.0]
assert math.isclose(_cosine(v, v), 1.0, rel_tol=1e-9)
def test_cosine_orthogonal_vectors():
a = [1.0, 0.0]
b = [0.0, 1.0]
assert math.isclose(_cosine(a, b), 0.0, abs_tol=1e-9)
def test_cosine_zero_vector_returns_zero():
assert _cosine([0.0, 0.0, 0.0], [1.0, 1.0, 1.0]) == 0.0
def test_cosine_empty_returns_zero():
assert _cosine([], [1.0]) == 0.0