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>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""H2 contract test: FreeCAD package translation reads the package once."""
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
import simplecadapi as scad
|
|
|
|
|
|
def _build_package() -> scad.ProductPackage:
|
|
@scad.part(id="single_box", project_root=Path(__file__).parent)
|
|
def build_box() -> scad.Part:
|
|
return scad.make_part_rpart(
|
|
"single_box", scad.make_box_rsolid(width=4.0, height=3.0, depth=2.0)
|
|
)
|
|
|
|
return scad.build_product_package(build_box())
|
|
|
|
|
|
class TestFreecadSingleRead(unittest.TestCase):
|
|
def test_translate_reads_package_units_once(self):
|
|
from simplecadapi.translator import package_units as pu
|
|
from simplecadapi.translator.freecad_translator import (
|
|
translate_product_package_to_freecad_script,
|
|
)
|
|
|
|
payload = scad.encode_product_package(_build_package())
|
|
reference = translate_product_package_to_freecad_script(payload)
|
|
|
|
with mock.patch.object(
|
|
pu,
|
|
"read_product_package_translation_units",
|
|
wraps=pu.read_product_package_translation_units,
|
|
) as spy:
|
|
script = translate_product_package_to_freecad_script(payload)
|
|
|
|
self.assertEqual(spy.call_count, 1)
|
|
self.assertEqual(script, reference)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|