|
|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import tempfile
|
|
|
|
|
import types
|
|
|
|
|
import unittest
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
@ -364,6 +366,40 @@ class WiringTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
self.assertNotIn("manual_wires", report)
|
|
|
|
|
|
|
|
|
|
def test_writeback_prefers_qet_exchange_json_directory_over_scene_directory(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _manual_wiring, write_back = _reload_modules()
|
|
|
|
|
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
|
|
|
|
|
old_scene = os.environ.get("QET_FREECAD_SCENE_FILE")
|
|
|
|
|
old_json = os.environ.get("QET_2D_TO_3D_JSON")
|
|
|
|
|
try:
|
|
|
|
|
with tempfile.TemporaryDirectory() as tmp_dir:
|
|
|
|
|
tmp_path = Path(tmp_dir)
|
|
|
|
|
scene_dir = tmp_path / "3D"
|
|
|
|
|
exchange_dir = tmp_path / ".qet_freecad"
|
|
|
|
|
scene_dir.mkdir()
|
|
|
|
|
exchange_dir.mkdir()
|
|
|
|
|
os.environ["QET_FREECAD_SCENE_FILE"] = str(scene_dir / "current.FCStd")
|
|
|
|
|
os.environ["QET_2D_TO_3D_JSON"] = str(exchange_dir / "2d_to_3d.json")
|
|
|
|
|
|
|
|
|
|
report = write_back.write_back_document(doc, payload={"project_uuid": "project-1"})
|
|
|
|
|
|
|
|
|
|
self.assertEqual(str(exchange_dir / "3d_to_2d.json"), report["output_path"])
|
|
|
|
|
self.assertTrue((exchange_dir / "3d_to_2d.json").is_file())
|
|
|
|
|
self.assertFalse((scene_dir / "3d_to_2d.json").exists())
|
|
|
|
|
finally:
|
|
|
|
|
if old_scene is None:
|
|
|
|
|
os.environ.pop("QET_FREECAD_SCENE_FILE", None)
|
|
|
|
|
else:
|
|
|
|
|
os.environ["QET_FREECAD_SCENE_FILE"] = old_scene
|
|
|
|
|
if old_json is None:
|
|
|
|
|
os.environ.pop("QET_2D_TO_3D_JSON", None)
|
|
|
|
|
else:
|
|
|
|
|
os.environ["QET_2D_TO_3D_JSON"] = old_json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|
|
|
|
|
|