From 30242d859e6813197448700c3d44a963b24b60f8 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 25 Apr 2025 13:00:40 +0500 Subject: [PATCH] Fix core test for drawing duplication (0b1c049) --- src/bonsai/bonsai/core/tool.py | 2 ++ src/bonsai/test/core/test_drawing.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/bonsai/bonsai/core/tool.py b/src/bonsai/bonsai/core/tool.py index fc928cf519..6135be093c 100644 --- a/src/bonsai/bonsai/core/tool.py +++ b/src/bonsai/bonsai/core/tool.py @@ -96,6 +96,7 @@ class Blender: def get_viewport_context(cls): pass def is_ifc_class_active(cls, ifc_class): pass def is_ifc_object(cls, obj): pass + def remove_object(cls, obj): pass def set_active_object(cls, obj): pass def update_viewport(cls): pass @@ -407,6 +408,7 @@ class Geometry: def delete_ifc_object(cls, obj): pass def delete_opening_object_placement(cls, opening): pass def does_representation_id_exist(cls, representation_id): pass + def duplicate_ifc_objects(cls, objects_to_duplicate, active_object=None, duplicate_ifc_objects=None): pass def duplicate_object_data(cls, obj): pass def get_blender_offset_type(cls, obj): pass def get_cartesian_point_offset(cls, obj): pass diff --git a/src/bonsai/test/core/test_drawing.py b/src/bonsai/test/core/test_drawing.py index cbfb56b652..d0f5902572 100644 --- a/src/bonsai/test/core/test_drawing.py +++ b/src/bonsai/test/core/test_drawing.py @@ -17,7 +17,7 @@ # along with Bonsai. If not, see . import bonsai.core.drawing as subject -from test.core.bootstrap import ifc, drawing, collector +from test.core.bootstrap import ifc, drawing, collector, geometry, blender, Prophecy class TestEnableEditingText: @@ -396,7 +396,7 @@ class TestAddDrawing: class TestDuplicateDrawing: - def test_run(self, ifc, drawing): + def test_run(self, ifc: Prophecy, blender: Prophecy, drawing: Prophecy, geometry: Prophecy): drawing.get_name("drawing").should_be_called().will_return("name") drawing.ensure_unique_drawing_name("name").should_be_called().will_return("unique_name") ifc.run("root.copy_class", product="drawing").should_be_called().will_return("new_drawing") @@ -410,8 +410,13 @@ class TestDuplicateDrawing: ).should_be_called() ifc.run("group.assign_group", group="new_group", products=["new_drawing"]).should_be_called() drawing.get_group_elements("group").should_be_called().will_return(["drawing", "annotation"]) - ifc.run("root.copy_class", product="annotation").should_be_called().will_return("new_annotation") - drawing.copy_representation("annotation", "new_annotation").should_be_called() + ifc.get_object("annotation").should_be_called().will_return("annotation_obj") + geometry.duplicate_ifc_objects(["annotation_obj"]).should_be_called().will_return( + ({"annotation": ["new_annotation"]}, None) + ) + ifc.get_object("new_annotation").should_be_called().will_return("new_annotation_obj") + blender.remove_object("new_annotation_obj").should_be_called() + ifc.run("group.unassign_group", group="group", products=["new_annotation"]).should_be_called() ifc.run("group.assign_group", group="new_group", products=["new_annotation"]).should_be_called() @@ -433,7 +438,7 @@ class TestDuplicateDrawing: ifc.run("document.assign_document", products=["new_drawing"], document="reference").should_be_called() drawing.import_drawings().should_be_called() - subject.duplicate_drawing(ifc, drawing, drawing="drawing", should_duplicate_annotations=True) + subject.duplicate_drawing(ifc, blender, drawing, geometry, drawing="drawing", should_duplicate_annotations=True) class TestRemoveDrawing: