diff --git a/tests/test_lesson_insight_round_trip.py b/tests/test_lesson_insight_round_trip.py index 8db7698..dd6bde4 100644 --- a/tests/test_lesson_insight_round_trip.py +++ b/tests/test_lesson_insight_round_trip.py @@ -48,7 +48,7 @@ from __future__ import annotations import pytest from scribe.services import lessons as lessons_svc -from tests.helpers import fake_note +from tests.helpers import fake_lesson WHAT = "A column written once at create time is a snapshot, not a field" @@ -92,10 +92,18 @@ IDS = [s[0] for s in SHAPES] def _stored(trigger: str, insight: str, sources: list[int]): """A lesson exactly as `create_lesson` writes it — title, body and mirror - composed together, which is the only way a real row is ever written.""" + composed together, which is the only way a real row is ever written. + + `fake_lesson` rather than `fake_note`, and the difference is load-bearing + here: `lesson_sources` falls back to `arose_from_id`, which on a bare + MagicMock auto-creates truthy and coerces to `1`. A no-sources shape then + recomposes with `**Learned from:** #1` and the round trip fails for a + reason that has nothing to do with the trigger. `fake_lesson` pins that + field to None — note #2109's point, which is why the fixture exists. + """ title, body = lessons_svc.lesson_document(WHAT, trigger, insight, sources) data = lessons_svc.compose_data(WHAT, trigger, sources) - return fake_note(title=title, body=body, data=data) + return fake_lesson(title=title, body=body, data=data) def _edit(note): @@ -149,7 +157,7 @@ def test_ten_edits_do_not_grow_the_record(_name, trigger, insight, sources): first = note.body for _ in range(10): title, body = _edit(note) - note = fake_note(title=title, body=body, data=note.data) + note = fake_lesson(title=title, body=body, data=note.data) assert note.body == first, ( f"body grew by {len(note.body) - len(first)} characters over ten no-op edits" ) @@ -180,7 +188,7 @@ def test_the_insight_is_derived_from_the_row_not_from_the_body_alone(): note = _stored(MANY_PARAGRAPHS, INSIGHT, []) assert lessons_svc.lesson_insight(note) == INSIGHT.strip() # The same body with the mirror removed cannot reach the same answer. - bare = fake_note(title=note.title, body=note.body, data=None) + bare = fake_lesson(title=note.title, body=note.body, data=None) assert lessons_svc.lesson_insight(bare) != INSIGHT.strip() @@ -190,7 +198,7 @@ def test_without_a_mirror_a_one_paragraph_trigger_still_strips(): correctly for the common shape — degrading to the old behaviour rather than to nothing.""" _, body = lessons_svc.lesson_document(WHAT, ONE_LINE, INSIGHT, [4199]) - bare = fake_note(title="t", body=body, data=None) + bare = fake_lesson(title="t", body=body, data=None) assert lessons_svc.lesson_insight(bare) == INSIGHT.strip() @@ -203,7 +211,7 @@ def test_a_stale_mirror_falls_back_rather_than_cutting_the_wrong_thing(): the insight, so the removal happens only on an exact match and the line-wise fallback takes over otherwise. Nothing authored is lost.""" _, body = lessons_svc.lesson_document(WHAT, ONE_LINE, INSIGHT, []) - stale = fake_note( + stale = fake_lesson( title="t", body=body, data={"what": WHAT, lessons_svc.TRIGGER_KEY: "a trigger that is not in this body"}, )