From 056e0b050d5d80bc2f498dee3db87e14206b577a Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 23 Oct 2023 17:25:07 +0500 Subject: [PATCH] fixed core tests after switch_representation changes --- src/blenderbim/blenderbim/core/geometry.py | 4 ++-- src/blenderbim/blenderbim/core/tool.py | 2 ++ src/blenderbim/test/core/test_geometry.py | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/core/geometry.py b/src/blenderbim/blenderbim/core/geometry.py index 42a05216a0..79150a8c25 100644 --- a/src/blenderbim/blenderbim/core/geometry.py +++ b/src/blenderbim/blenderbim/core/geometry.py @@ -104,7 +104,7 @@ def switch_representation( return entity = ifc.get_entity(obj) - current_obj_data = obj.data + current_obj_data = geometry.get_object_data(obj) has_openings = apply_openings and getattr(entity, "HasOpenings", None) if has_openings: @@ -131,7 +131,7 @@ def switch_representation( if should_reload and old_repr_data: # if current object was using some temporary mesh (like during profile edit mode) instead of `old_repr_data` # then `change_object_data` won't switch the mesh for all the occurences and we need to do it explicitly - if current_obj_data != old_repr_data and old_repr_data.users: + if current_obj_data != old_repr_data and geometry.has_data_users(old_repr_data): geometry.replace_object_data_globally(old_repr_data, new_repr_data) geometry.delete_data(old_repr_data) diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index 070773c457..076787b378 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -370,6 +370,7 @@ class Geometry: def remove_connection(cls, connection): pass def rename_object(cls, obj, name): pass def replace_object_with_empty(cls, obj): pass + def replace_object_data_globally(cls, old_data, new_data): pass def resolve_mapped_representation(cls, representation): pass def run_geometry_update_representation(cls, obj=None): pass def run_style_add_style(cls, obj=None): pass @@ -378,6 +379,7 @@ class Geometry: def should_force_triangulation(cls): pass def should_generate_uvs(cls, obj): pass def should_use_presentation_style_assignment(cls): pass + def unresolve_type_representation(cls, representation, element): pass @interface diff --git a/src/blenderbim/test/core/test_geometry.py b/src/blenderbim/test/core/test_geometry.py index 354cb8781d..87dfbc4f67 100644 --- a/src/blenderbim/test/core/test_geometry.py +++ b/src/blenderbim/test/core/test_geometry.py @@ -192,6 +192,7 @@ class TestAddRepresentation: class TestSwitchRepresentation: def test_switching_to_a_freshly_loaded_representation(self, ifc, geometry): geometry.is_edited("obj").should_be_called().will_return(False) + geometry.get_object_data("obj").should_be_called().will_return("current_obj_data") geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") geometry.get_representation_data("representation").should_be_called().will_return(None) geometry.import_representation("obj", "representation", apply_openings=True).should_be_called().will_return("new_data") @@ -216,6 +217,7 @@ class TestSwitchRepresentation: def test_switching_to_a_reloaded_representation_and_deleting_the_existing_data(self, ifc, geometry): geometry.is_edited("obj").should_be_called().will_return(False) + geometry.get_object_data("obj").should_be_called().will_return("current_obj_data") geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") geometry.get_representation_data("representation").should_be_called().will_return("existing_data") geometry.import_representation("obj", "representation", apply_openings=True).should_be_called().will_return("new_data") @@ -224,6 +226,7 @@ class TestSwitchRepresentation: geometry.link("representation", "new_data").should_be_called() geometry.change_object_data("obj", "new_data", is_global=True).should_be_called() geometry.record_object_materials("obj").should_be_called() + geometry.has_data_users("existing_data").should_be_called().will_return(False) geometry.delete_data("existing_data").should_be_called() geometry.clear_modifiers("obj").should_be_called() ifc.get_entity("obj").should_be_called().will_return("element") @@ -241,6 +244,7 @@ class TestSwitchRepresentation: def test_switching_to_an_existing_representation(self, ifc, geometry): geometry.is_edited("obj").should_be_called().will_return(False) + geometry.get_object_data("obj").should_be_called().will_return("current_obj_data") geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") geometry.get_representation_data("representation").should_be_called().will_return("data") geometry.change_object_data("obj", "data", is_global=True).should_be_called() @@ -264,6 +268,7 @@ class TestSwitchRepresentation: geometry.get_representation_id("mapped_rep").should_be_called().will_return("representation_id") geometry.run_geometry_update_representation(obj="obj").should_be_called() geometry.does_representation_id_exist("representation_id").should_be_called().will_return(True) + geometry.get_object_data("obj").should_be_called().will_return("current_obj_data") geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation") geometry.get_representation_data("representation").should_be_called().will_return("data") geometry.change_object_data("obj", "data", is_global=False).should_be_called()