Fix bug where removing a representation from a typed instance didn't remove all data users.

This commit is contained in:
Dion Moult
2021-11-08 21:02:04 +11:00
parent bf134eb0f4
commit 0471f17d9a
4 changed files with 137 additions and 0 deletions
+53
View File
@@ -255,3 +255,56 @@ class TestSwitchRepresentation:
enable_dynamic_voids=False,
is_global=False,
)
class TestRemoveRepresentation:
def test_removing_an_actively_used_mapped_representation_by_remapping_usages_to_an_empty(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.is_mapped_representation("mapped_rep").should_be_called().will_return(False)
geometry.is_type_product("element").should_be_called().will_return(True)
geometry.get_element_type("element").should_be_called().will_return("type")
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
geometry.get_representation_data("representation").should_be_called().will_return("data")
geometry.has_data_users("data").should_be_called().will_return(True)
geometry.get_elements_of_type("type").should_be_called().will_return(["element"])
ifc.get_object("element").should_be_called().will_return("obj")
geometry.replace_object_with_empty("obj").should_be_called()
ifc.get_object("type").should_be_called().will_return("type_obj")
geometry.replace_object_with_empty("type_obj").should_be_called()
ifc.run("geometry.unassign_representation", product="type", representation="representation").should_be_called()
ifc.run("geometry.remove_representation", representation="representation").should_be_called()
subject.remove_representation(ifc, geometry, obj="obj", representation="mapped_rep")
def test_removing_an_unused_mapped_representation(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.is_mapped_representation("mapped_rep").should_be_called().will_return(True)
geometry.get_element_type("element").should_be_called().will_return("type")
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
geometry.get_representation_data("representation").should_be_called().will_return(None)
ifc.run("geometry.unassign_representation", product="type", representation="representation").should_be_called()
ifc.run("geometry.remove_representation", representation="representation").should_be_called()
subject.remove_representation(ifc, geometry, obj="obj", representation="mapped_rep")
def test_removing_an_actively_used_representation(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.is_mapped_representation("representation").should_be_called().will_return(False)
geometry.is_type_product("element").should_be_called().will_return(False)
geometry.get_representation_data("representation").should_be_called().will_return("data")
geometry.has_data_users("data").should_be_called().will_return(True)
geometry.replace_object_with_empty("obj").should_be_called()
ifc.run(
"geometry.unassign_representation", product="element", representation="representation"
).should_be_called()
ifc.run("geometry.remove_representation", representation="representation").should_be_called()
subject.remove_representation(ifc, geometry, obj="obj", representation="representation")
def test_removing_an_unused_representation(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.is_mapped_representation("representation").should_be_called().will_return(False)
geometry.is_type_product("element").should_be_called().will_return(False)
geometry.get_representation_data("representation").should_be_called().will_return(None)
ifc.run(
"geometry.unassign_representation", product="element", representation="representation"
).should_be_called()
ifc.run("geometry.remove_representation", representation="representation").should_be_called()
subject.remove_representation(ifc, geometry, obj="obj", representation="representation")