Checklists in the body, colour from tags, and commit-derived CalVer #4
@@ -19,6 +19,7 @@ from thoughtsync.notes import (
|
|||||||
_header_filename,
|
_header_filename,
|
||||||
_keep_spec,
|
_keep_spec,
|
||||||
_native_spec,
|
_native_spec,
|
||||||
|
_note_markdown,
|
||||||
_safe_filename,
|
_safe_filename,
|
||||||
_slugify,
|
_slugify,
|
||||||
_usec_to_dt,
|
_usec_to_dt,
|
||||||
@@ -533,3 +534,39 @@ def test_the_migration_folds_exactly_like_the_app():
|
|||||||
("prose\n", " padded ", True),
|
("prose\n", " padded ", True),
|
||||||
]:
|
]:
|
||||||
assert module._append_item(body, text, checked) == append_item(body, text, checked)
|
assert module._append_item(body, text, checked) == append_item(body, text, checked)
|
||||||
|
|
||||||
|
|
||||||
|
# --- import/export: the body already carries the list ------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_note_markdown_writes_a_checklist_once():
|
||||||
|
"""The export used to append the items after the body. The body IS them now
|
||||||
|
(M304), so the old branch would have doubled every checklist in an export — and
|
||||||
|
doubled it again on the next re-import."""
|
||||||
|
note = Note(
|
||||||
|
display_title="shopping",
|
||||||
|
body="shopping\n\n- [ ] milk\n- [x] eggs",
|
||||||
|
color="default",
|
||||||
|
pinned=False,
|
||||||
|
archived=False,
|
||||||
|
)
|
||||||
|
out = _note_markdown(note, [])
|
||||||
|
assert out.count("- [ ] milk") == 1
|
||||||
|
assert out.count("- [x] eggs") == 1
|
||||||
|
# And in place, under the note's own first line rather than in a block of its own.
|
||||||
|
assert out.rstrip().endswith("shopping\n\n- [ ] milk\n- [x] eggs")
|
||||||
|
|
||||||
|
|
||||||
|
def test_native_spec_of_a_current_export_folds_nothing():
|
||||||
|
# Today's export carries no `items` key, because the body has the lines. An empty
|
||||||
|
# list is what stops _insert_note folding them in a second time.
|
||||||
|
assert _native_spec({"body": "a\n\n- [ ] milk"})["items"] == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_native_spec_of_a_pre_m304_export_still_carries_its_items():
|
||||||
|
# An export taken BEFORE this milestone has a body with no task lines and a
|
||||||
|
# separate items array. Importing one has to put the checklist back — which is
|
||||||
|
# the same fold the Keep importer does, and the reason _insert_note still accepts
|
||||||
|
# items at all.
|
||||||
|
old = {"body": "shopping", "items": [{"text": "milk", "checked": True}]}
|
||||||
|
assert _native_spec(old)["items"] == [{"text": "milk", "checked": True}]
|
||||||
|
|||||||
Reference in New Issue
Block a user