Files
inkwell/tests/test_portable_fixture.py
T
bvandeusenandClaude Opus 5.5 5989ffc1c6
CI & Build / Build now, or wait for Android? (push) Successful in 4s
Android / Build, or is the channel already serving this? (push) Successful in 4s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 12s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Python tests (push) Successful in 13s
CI & Build / integration (push) Successful in 48s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 4m26s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 3m32s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 4m10s
Desktop (Tauri) / Update manifest (push) Successful in 4s
Android / Kotlin + Rust (APK) (push) Successful in 12m42s
desktop: Import and Export work offline; the menu toggle is reachable; errors say why
Export and Import were a link to the server and a reject("needs a server") on the
desktop. Both now run in the core with no server:

- core/src/local/portable.rs builds the same zip the server writes (notes.json,
  a Markdown file per note, each attachment this device holds) and reads either
  export marker or a Google Keep Takeout zip, with the server's decompression
  budget and an all-or-nothing transaction. Export saves to Downloads (no new
  plugin) and the sidebar says where; Import takes the archive as raw IPC bytes.
- core/testdata/portable.json pins the format for both copies: the server runs
  its Keep and native readers against it (test_portable_fixture.py) and checks
  its real export's keys (test_integration.py); the core runs the same cases.
- Found on the way: both importers skipped a Keep note that is only a photo as
  "empty". It now imports, on the server and in the core.
- New dependency, approved: `zip` (deflate only) plus `flate2` on its pure-Rust
  backend, both already in the lockfile.

The AppImage applications-menu toggle moves from Account, which the desktop
never shows, to the Sync page; the first-run prompt now says so.

errorMessage (#5236) replaces the hand-rolled `.error ?? …` / `.message ?? e`
reads at the remaining catch sites, so a desktop failure shows its real reason.

Task #5170.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 11:36:42 -04:00

43 lines
1.5 KiB
Python

"""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"])