pivot to Python: replace Kotlin/JVM with stdlib zipapp
Reasons stacked up:
- AV: unsigned JARs that auto-download binaries + upload files trigger
Windows Defender false-positives more often than Python scripts
invoked by code-signed python.exe.
- Qt UI option: PySide6 opens a path to a real Qt UI (matching Prism's
look) if needed later. JVM Qt bindings are abandoned.
- frazclient already needs Python; inlining as 'import cloud_sync' is
zero overhead vs the launcher always shelling out to java.
Implementation:
- cloud_sync package: cli.py (argparse), creds.py, scope.py,
restic.py (binary discovery + auto-download + sha256 verify),
sync.py (pull/push subprocess restic).
- pyproject.toml with hatchling backend; pip-installable.
- Makefile builds cloud-sync.pyz via python -m zipapp (~53 KB).
- 33 pytest tests, stdlib only on runtime.
- CI workflow runs pytest matrix (3.10/3.11/3.12) + builds pyz.
- DESIGN.md + README.md updated to reflect Python.
E2E verified against local restic-rest-server:
pull empty → push initial → rm -rf local → pull restores → modify+push
creates second snapshot → client forget --prune blocked by --append-only.
Throws away ~565 LOC of Kotlin (and 18 jar tests) committed earlier in
this same session. Net result is ~250 LOC Python + 33 tests = smaller
and more aligned with the rest of the stack.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
"""CLI parsing tests — argv → (subcommand, Args)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from cloud_sync.cli import Args, parse
|
||||
|
||||
|
||||
def test_parses_pull_with_required_url() -> None:
|
||||
cmd, args = parse(["pull", "--url=https://cloud.tm.center"])
|
||||
assert cmd == "pull"
|
||||
assert isinstance(args, Args)
|
||||
assert args.url == "https://cloud.tm.center"
|
||||
assert args.allow_download is True
|
||||
assert args.headless is False
|
||||
|
||||
|
||||
def test_default_token_file_under_pack_folder() -> None:
|
||||
_, args = parse(["pull", "--url=https://x", "--pack-folder=/tmp/inst"])
|
||||
assert args.token_file.as_posix().endswith(".cloud-sync/token")
|
||||
assert "/tmp/inst" in args.token_file.as_posix()
|
||||
|
||||
|
||||
def test_custom_token_file_overrides_default() -> None:
|
||||
_, args = parse(
|
||||
["pull", "--url=https://x", "--pack-folder=/tmp/inst",
|
||||
"--token-file=/etc/cloud-creds"]
|
||||
)
|
||||
assert args.token_file.as_posix() == "/etc/cloud-creds"
|
||||
|
||||
|
||||
def test_inline_and_space_separated_both_work() -> None:
|
||||
_, a1 = parse(["pull", "--url=https://x", "--pack-folder=/srv"])
|
||||
_, a2 = parse(["pull", "--url", "https://x", "--pack-folder", "/srv"])
|
||||
assert a1.url == a2.url
|
||||
assert a1.pack_folder == a2.pack_folder
|
||||
|
||||
|
||||
def test_no_gui_flag() -> None:
|
||||
_, a = parse(["push", "--url=https://x", "-g"])
|
||||
assert a.headless is True
|
||||
_, b = parse(["push", "--url=https://x", "--no-gui"])
|
||||
assert b.headless is True
|
||||
|
||||
|
||||
def test_no_download_flag() -> None:
|
||||
_, a = parse(["push", "--url=https://x", "--no-download"])
|
||||
assert a.allow_download is False
|
||||
|
||||
|
||||
def test_restic_binary_override() -> None:
|
||||
_, a = parse(["push", "--url=https://x", "--restic-binary=/opt/restic"])
|
||||
assert a.restic_binary is not None
|
||||
assert a.restic_binary.as_posix() == "/opt/restic"
|
||||
|
||||
|
||||
def test_missing_url_exits() -> None:
|
||||
with pytest.raises(SystemExit):
|
||||
parse(["pull"])
|
||||
|
||||
|
||||
def test_missing_subcommand_exits() -> None:
|
||||
with pytest.raises(SystemExit):
|
||||
parse([])
|
||||
|
||||
|
||||
def test_unknown_subcommand_exits() -> None:
|
||||
with pytest.raises(SystemExit):
|
||||
parse(["bogus", "--url=https://x"])
|
||||
|
||||
|
||||
def test_pack_folder_is_resolved_to_absolute() -> None:
|
||||
_, a = parse(["pull", "--url=https://x", "--pack-folder=."])
|
||||
assert a.pack_folder.is_absolute()
|
||||
Reference in New Issue
Block a user