- TOOL_PROFILE=lean|core|full applied in the lifespan via server-level enable/disable; system_about reports the active profile; opt-in solid_* tools are hidden while ENABLE_3D=false - layouts: layout_list/create/set_current + viewport_create (scaled model viewports) on both backends; drawing_export_pdf(layout=...); ezdxf uses TILEMODE + active-layout binding, COM switches ActiveLayout and restores it - ISO 286: engineering/fits.py authored IT4-11 + fundamental-deviation tables (1-500 mm; shafts d..p/h/js, holes D..H/JS) with clear out-of-scope errors; dimension_linear/radius/diameter gained fit= resolved from the measured nominal - tolerances: DIMTM now signed in deviation/limit modes so double-positive fits (p6 +0.035/+0.022) render correctly; legacy positive-magnitude contract preserved - solids: solid_box/cylinder/extrude/revolve/boolean native on COM (AddBox/AddCylinder/AddRegion+AddExtrudedSolid/AddRevolvedSolid/Boolean); ezdxf reports the honest solid_3d capability boundary - capability maps: paper_space native, new viewport_render feature, ENABLE_3D-gated solid_3d - 60 new tests (profiles, layouts, viewports, layout PDF, fits, gating); version pins in tests now read version.__version__ Co-authored-by: Cursor <cursoragent@cursor.com>
80 lines
2.3 KiB
Python
80 lines
2.3 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from backends.base import CapabilityMap, FeatureCapability
|
|
from version import __version__
|
|
|
|
|
|
def test_capability_types_serialize_stably():
|
|
caps = CapabilityMap(
|
|
backend="demo",
|
|
features={"table": FeatureCapability(True, "native")},
|
|
)
|
|
|
|
assert caps.to_dict() == {
|
|
"backend": "demo",
|
|
"features": {
|
|
"table": {"supported": True, "mode": "native", "reason": None},
|
|
},
|
|
}
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_ezdxf_capabilities_are_machine_readable(backend):
|
|
caps = backend.capabilities().to_dict()
|
|
|
|
assert caps["backend"] == "ezdxf"
|
|
assert caps["features"]["table"] == {
|
|
"supported": True,
|
|
"mode": "composite",
|
|
"reason": None,
|
|
}
|
|
assert caps["features"]["mleader"]["mode"] == "composite"
|
|
# v1.4: paper-space layouts/viewports are native on both backends;
|
|
# projecting model content through viewports stays COM-only, and 3D
|
|
# ACIS solids remain impossible headlessly.
|
|
assert caps["features"]["paper_space"]["supported"] is True
|
|
assert caps["features"]["viewport_render"]["supported"] is False
|
|
assert caps["features"]["solid_3d"]["supported"] is False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_ezdxf_render_capabilities_follow_optional_dependency(backend):
|
|
with patch("backends.ezdxf_backend.find_spec", return_value=None):
|
|
caps = backend.capabilities().to_dict()
|
|
|
|
assert caps["features"]["pdf"] == {
|
|
"supported": False,
|
|
"mode": None,
|
|
"reason": "optional_dependency_missing:matplotlib",
|
|
}
|
|
assert caps["features"]["png"]["supported"] is False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_system_capabilities_tool_uses_backend_map(backend):
|
|
import server
|
|
|
|
class Ctx:
|
|
lifespan_context = {"backend": backend}
|
|
|
|
result = await server.system_capabilities(ctx=Ctx())
|
|
|
|
assert result == backend.capabilities().to_dict()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_system_about_uses_package_version_and_capability_summary(backend):
|
|
import server
|
|
|
|
class Ctx:
|
|
lifespan_context = {"backend": backend}
|
|
|
|
result = await server.system_about(ctx=Ctx())
|
|
|
|
assert result["version"] == __version__
|
|
assert result["capabilities"]["table"]["mode"] == "composite"
|