b939f44043
- simplecad-cache/simplecad-export entry points are gone (hard cut): the same commands live under the unified dispatcher (simplecadapi.cli) as 'sca cache ...' and 'sca export ...', each group registered at parser level so per-group --help works - sca init now wires the shell by default (--no-shell skips): a ~/.sca/bin/sca shim (Windows sca.cmd) execs the installing venv's console script — the venv bin itself never goes on PATH — and the shim dir lands on PATH via a marked, removable block in ~/.zshenv (read by non-interactive shells, so agents see the command), ~/.bashrc, fish conf.d, or the Windows user PATH registry value with a change broadcast; rc files are created only for the login shell or when they already exist; re-running init refreshes the shim (target discovery is symlink-safe, no resolve() out of venv) - addon/cache/export cli modules expose configure(subparsers) + _execute(args); module run() keeps the CLI-shaped argv - docs: sca namespace across evergreen docs, shell-integration section, 'never writes shell profiles' contract line retired - tests: +17 (dispatcher groups, shell integration, entry-point absence); cache/export suites moved to group-token argv
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
from pathlib import Path
|
|
|
|
from simplecadapi.exporter import cli
|
|
|
|
|
|
class _Package:
|
|
root_kind = "part"
|
|
root_id = "part-bracket"
|
|
|
|
|
|
def test_check_defaults_to_step_stl_and_obj(monkeypatch, tmp_path: Path):
|
|
input_path = tmp_path / "bracket.scadpkg"
|
|
monkeypatch.setattr(cli, "read_product_package", lambda value: _Package())
|
|
|
|
report, exit_code = cli.run(["export", str(input_path), "--check", "--output-dir", str(tmp_path / "out")])
|
|
|
|
assert exit_code == 0
|
|
assert report["check_only"] is True
|
|
assert set(report["formats"]) == {"step", "stl", "obj"}
|
|
assert report["formats"]["step"]["output"].endswith("bracket.step")
|
|
assert report["formats"]["stl"]["output"].endswith("bracket.stl")
|
|
assert report["formats"]["obj"]["output"].endswith("bracket.obj")
|
|
|
|
|
|
def test_check_fcstd_reports_missing_freecad(monkeypatch, tmp_path: Path):
|
|
monkeypatch.setattr(cli, "read_product_package", lambda value: _Package())
|
|
monkeypatch.setattr(cli, "discover_freecad_executable", lambda: None)
|
|
|
|
report, exit_code = cli.run(["export", str(tmp_path / "part.scadpkg"), "--format", "fcstd", "--check"])
|
|
|
|
assert exit_code == 1
|
|
assert report["formats"]["fcstd"]["ok"] is False
|
|
assert "FreeCADCmd" in report["formats"]["fcstd"]["issues"][0]
|
|
|
|
|
|
def test_check_mjcf_requires_assembly(monkeypatch, tmp_path: Path):
|
|
monkeypatch.setattr(cli, "read_product_package", lambda value: _Package())
|
|
|
|
report, exit_code = cli.run(["export", str(tmp_path / "part.scadpkg"), "--format", "mjcf", "--check"])
|
|
|
|
assert exit_code == 1
|
|
assert report["formats"]["mjcf"]["ok"] is False
|
|
|
|
|
|
def test_check_rejects_unknown_package_extension(tmp_path: Path):
|
|
try:
|
|
cli.run(["export", str(tmp_path / "part.json"), "--check"])
|
|
except ValueError as exc:
|
|
assert ".scadpkg" in str(exc)
|
|
else:
|
|
raise AssertionError("expected .scadpkg validation error")
|
|
|
|
|
|
def test_output_override_requires_selected_optional_format(tmp_path: Path):
|
|
try:
|
|
cli.run(["export", str(tmp_path / "part.scadpkg"), "--check", "--output", "fcstd=part.FCStd"])
|
|
except ValueError as exc:
|
|
assert "--format" in str(exc)
|
|
else:
|
|
raise AssertionError("expected unselected format validation error")
|