Fix #3764. WARNING: Preserve material usage attributes when switching types and refactor type regeneration API listeners

This is a dangerous commit because the effect of refactoring of the listeners is hard to know.
This commit is contained in:
Dion Moult
2026-01-26 23:30:39 +11:00
parent f725e05655
commit 44a52863a2
13 changed files with 54 additions and 105 deletions
+4 -4
View File
@@ -17,11 +17,11 @@
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
import bonsai.core.type as subject
from test.core.bootstrap import geometry, ifc, type
from test.core.bootstrap import ifc, model, type, geometry
class TestAssignType:
def test_assigning_and_switching_to_an_existing_type_data(self, ifc, type):
def test_assigning_and_switching_to_an_existing_type_data(self, ifc, model, type):
ifc.run("type.assign_type", related_objects=["element"], relating_type="type").should_be_called()
type.has_material_usage("element").should_be_called().will_return(False)
ifc.get_object("type").should_be_called().will_return("type_obj")
@@ -29,7 +29,7 @@ class TestAssignType:
type.change_object_data("obj", "type_obj_data", is_global=False).should_be_called()
ifc.get_object("element").should_be_called().will_return("obj")
type.disable_editing("obj").should_be_called()
subject.assign_type(ifc, type, element="element", type="type")
subject.assign_type(ifc, model, type, element="element", type="type")
def test_assigning_and_not_changing_data_if_the_type_has_no_data(self, ifc, type):
ifc.run("type.assign_type", related_objects=["element"], relating_type="type").should_be_called()
@@ -38,7 +38,7 @@ class TestAssignType:
type.get_object_data("type_obj").should_be_called().will_return(None)
ifc.get_object("element").should_be_called().will_return("obj")
type.disable_editing("obj").should_be_called()
subject.assign_type(ifc, type, element="element", type="type")
subject.assign_type(ifc, model, type, element="element", type="type")
class TestPurgeUnusedTypes: