mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-08-06 15:55:46 +00:00
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import ezdxf
|
|
|
|
from common.dxf import build_dxf_render_payload
|
|
|
|
|
|
class CadgenDxfTests(unittest.TestCase):
|
|
def test_build_dxf_render_payload_supports_straight_lwpolyline(self) -> None:
|
|
with tempfile.TemporaryDirectory(prefix="tmp-cad-dxf-") as tmpdir:
|
|
dxf_path = Path(tmpdir) / "outline.dxf"
|
|
doc = ezdxf.new("R2010")
|
|
modelspace = doc.modelspace()
|
|
modelspace.add_lwpolyline(
|
|
[(0.0, 0.0), (10.0, 0.0), (10.0, 5.0), (0.0, 5.0)],
|
|
close=True,
|
|
dxfattribs={"layer": "CUT"},
|
|
)
|
|
doc.saveas(dxf_path)
|
|
|
|
payload = build_dxf_render_payload(dxf_path, file_ref="test/outline.dxf")
|
|
|
|
self.assertEqual(4, payload["counts"]["paths"])
|
|
self.assertEqual(0, payload["counts"]["circles"])
|
|
self.assertEqual(4, len(payload["geometry"]["lines"]))
|
|
self.assertEqual(10.0, payload["bounds"]["width"])
|
|
self.assertEqual(5.0, payload["bounds"]["height"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|