"""The server's half of the shared export/import fixture (core/testdata/portable.json). The core runs the same cases (local/portable.rs), because the desktop exports and imports offline with its own copy of this format. A case that passes here and fails there is a backup that loses something when it crosses from one surface to the other. """ from __future__ import annotations import json from pathlib import Path import pytest from inkwell.common import parse_dt from inkwell.notes.import_export import _keep_spec, _native_spec FIXTURE = json.loads( (Path(__file__).resolve().parents[1] / "core" / "testdata" / "portable.json").read_text(encoding="utf-8") ) _TIMES = ("created_at", "updated_at", "remind_at") def _assert_spec(got: dict, want: dict) -> None: # Only the keys the fixture names: each importer may carry more, but none may # disagree on these. Timestamps compare as instants, since the server holds # datetimes and the core holds strings. for key, expected in want.items(): if key in _TIMES: assert got.get(key) == parse_dt(expected), key else: assert got.get(key) == expected, key @pytest.mark.parametrize("case", FIXTURE["keep"], ids=lambda c: c["about"]) def test_keep_notes(case): _assert_spec(_keep_spec(case["note"], case["dir"]), case["spec"]) @pytest.mark.parametrize("case", FIXTURE["native"], ids=lambda c: c["about"]) def test_native_notes(case): _assert_spec(_native_spec(case["note"]), case["spec"])