mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
fixed core tests after switch_representation changes
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user