3dd8c77b8d
A SimpleCAD model is now a marimo notebook: a PEP 723 header with a [tool.simplecadapi] table (id, revision, tolerance_profile, inputs), one FTC block per cell, and the product is the top-level value whose id is the notebook id. The notebook file is the only source of truth; .scadpkg is only for exchange and publishing. Runtime (simplecadapi.runtime): - run_notebook(path, *, id=None, overrides=None, cache=True) and sca run <notebook.py> [--id] [--set NAME=VALUE] [--no-cache] [--out] - use(path, id=..., **overrides) composes child notebooks; notebook_id() lets one notebook serve a part family under per-use ids - each cell records into its own session; cells are the unit of caching, keyed by the notebook dependency digest (deps.json) - marimo cell executor entry point, so marimo edit runs the same way - shapes and read-only definition mappings pickle for the cell cache Removed: the content-addressed part cache (simplecadapi.cache, CachePolicy, CacheReport, sca cache ...), the incremental assembly solver and its dependency/state modules, and part-interface diffs with latest- state persistence. Part and assembly builds and the notebook projection now share one definition writer (build/definition.py). Co-Authored-By: Claude Code <noreply@anthropic.com>
82 lines
2.6 KiB
Python
82 lines
2.6 KiB
Python
"""Tests for the unified ``sca`` entry point (:mod:`simplecadapi.cli`)."""
|
|
|
|
from importlib.metadata import entry_points
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from simplecadapi.cli import run
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def fake_user_home(tmp_path, monkeypatch):
|
|
monkeypatch.setattr(Path, "home", lambda: tmp_path)
|
|
monkeypatch.delenv("SCA_ADDON_HOME", raising=False)
|
|
monkeypatch.delenv("SCA_SKILLS_DIR", raising=False)
|
|
return tmp_path
|
|
|
|
|
|
def test_init_group_runs_with_shell_integration(tmp_path, monkeypatch):
|
|
# Pin the shell: the integration targets zsh only when SHELL says so
|
|
# (or ~/.zshenv already exists); CI runners run bash.
|
|
monkeypatch.setenv("SHELL", "/bin/zsh")
|
|
report, code, printer = run(["init"])
|
|
assert code == 0
|
|
assert Path(report["home"]) == tmp_path / ".sca" / "addons"
|
|
assert report["shell"]["shim"]
|
|
assert (tmp_path / ".zshenv").is_file()
|
|
assert callable(printer)
|
|
|
|
|
|
def test_init_no_shell_writes_no_shim(tmp_path):
|
|
report, code, _ = run(["init", "--no-shell"])
|
|
assert code == 0
|
|
assert report["shell"] == {"skipped": True}
|
|
assert not (tmp_path / ".sca" / "bin").exists()
|
|
|
|
|
|
def test_addon_group_dispatches(tmp_path):
|
|
run(["init"])
|
|
report, code, _ = run(["addon", "list"])
|
|
assert code == 0
|
|
assert report["addons"] == []
|
|
|
|
|
|
def test_cache_group_is_gone():
|
|
# The part cache was removed; code is the only source of truth.
|
|
with pytest.raises(SystemExit) as excinfo:
|
|
run(["cache", "status"])
|
|
assert excinfo.value.code == 2
|
|
|
|
|
|
def test_export_group_dispatches(tmp_path, monkeypatch):
|
|
from simplecadapi.exporter import cli as export_cli
|
|
|
|
package = type("P", (), {"root_kind": "part", "root_id": "part-bracket"})
|
|
monkeypatch.setattr(export_cli, "read_product_package", lambda value: package)
|
|
pkg = tmp_path / "bracket.scadpkg"
|
|
pkg.write_bytes(b"stub")
|
|
|
|
report, code, _ = run(
|
|
["export", str(pkg), "--check", "--output-dir", str(tmp_path / "out")]
|
|
)
|
|
assert code == 0
|
|
assert report["ok"] is True
|
|
assert set(report["formats"]) == {"step", "stl", "obj"}
|
|
|
|
|
|
def test_version_reports_the_sdk_version(capsys):
|
|
from simplecadapi.addon.install import sca_version
|
|
|
|
with pytest.raises(SystemExit) as excinfo:
|
|
run(["--version"])
|
|
assert excinfo.value.code == 0
|
|
assert sca_version() in capsys.readouterr().out
|
|
|
|
|
|
def test_legacy_entry_points_are_gone():
|
|
scripts = {ep.name for ep in entry_points(group="console_scripts")}
|
|
assert "sca" in scripts
|
|
assert "simplecad-cache" not in scripts
|
|
assert "simplecad-export" not in scripts
|