Avoid producing test artifacts in src/bonsai

This commit is contained in:
Andrej730
2025-11-11 19:37:11 +05:00
parent 7f8cb80281
commit 25d3edc537
5 changed files with 25 additions and 5 deletions
-3
View File
@@ -88,9 +88,6 @@ src/bonsai/bonsai/bim/data/gantt/jsgantt.js
src/bonsai/bonsai/bim/data/gantt/jsgantt.css
src/bonsai/bonsai/bim/data/webui/static/js/jquery.min.js
src/bonsai/drawings
src/bonsai/layouts
# ifcopenshell swig and compiled files
src/ifcopenshell-python/ifcopenshell/_ifcopenshell_wrapper*.so
src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.py
@@ -3461,6 +3461,15 @@ class LoadDrawings(bpy.types.Operator, tool.Ifc.Operator):
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
# Operator is not accessible through UI if IFC project is not saved,
# but adding poll check to avoid using Drawings UI in scripts with unsaved project.
if tool.Ifc.get_path():
return True
cls.poll_message_set("IFC project is not saved.")
return False
def _execute(self, context):
core.load_drawings(tool.Drawing)
+9
View File
@@ -18,6 +18,7 @@
from __future__ import annotations
import os
import shutil
import bpy
import ifcopenshell
import ifcopenshell.api.document
@@ -502,3 +503,11 @@ class Project(bonsai.core.tool.Project):
d2 = v3 - v2
normals.append((v1, d1.cross(d2).normalized()))
return normals
@classmethod
def save_test_project(cls) -> None:
TMP = Path.cwd() / "test/files/temp"
# Clean up previous test project.
if TMP.exists():
shutil.rmtree(TMP)
bpy.ops.bim.save_project(filepath=(TMP / "test_project.ifc").__str__(), should_save_as=True)
+4 -1
View File
@@ -157,13 +157,16 @@ Scenario: Remove drawing
Scenario: Remove drawing - via object deletion
Given an empty IFC project
And I save IFC project
And I add a cube
And the object "Cube" is selected
And I look at the "Class" panel
And I set the "Products" property to "IfcElement"
And I set the "Class" property to "IfcWall"
And I click "Assign IFC Class"
And I press "bim.add_drawing"
And I look at the "Drawings" panel
And I click "IMPORT"
And I click "ADD"
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
And the collection "IfcAnnotation/PLAN_VIEW" exists
And the object "IfcAnnotation/PLAN_VIEW" is selected
+3 -1
View File
@@ -815,8 +815,9 @@ class TestDrawingMaintainingSheetPosition(NewFile):
def test_run(self):
props = tool.Drawing.get_document_props()
bpy.ops.bim.create_project()
tool.Project.save_test_project()
ifc = tool.Ifc.get()
sheet_path = Path.cwd() / "layouts" / "A01 - UNTITLED.svg"
sheet_path = Path(tool.Ifc.get_path()).parent / "layouts" / "A01 - UNTITLED.svg"
bpy.ops.mesh.primitive_cube_add(size=10, location=(0, 0, 4))
obj = bpy.data.objects["Cube"]
@@ -870,6 +871,7 @@ class TestDrawingMaintainingSheetPosition(NewFile):
class TestDrawingStyles(NewFile):
def setup_project_with_drawing(self):
bpy.ops.bim.create_project()
tool.Project.save_test_project()
bpy.ops.bim.load_drawings()
bpy.ops.bim.add_drawing()
ifc = tool.Ifc.get()