Add annotation by default to the active drawing #5216

Approach in 358c834 didn't worked out because annotations are assigned to the drawing after assign_class and we can't check in assign_class whether it's going to be part of the drawing.
This commit is contained in:
Andrej730
2024-08-26 15:18:20 +05:00
parent 5aa7758795
commit 286e90e299
4 changed files with 44 additions and 8 deletions
+30
View File
@@ -130,6 +130,7 @@ class TestAssignClass:
obj="obj", context="context", ifc_representation_class="ifc_representation_class", profile_set_usage=None
).should_be_called()
root.is_drawing_annotation("element").should_be_called().will_return(False)
root.get_default_container().should_be_called().will_return("default_container")
root.is_spatial_element("element").should_be_called().will_return(True)
ifc.run("aggregate.assign_object", products=["element"], relating_object="default_container").should_be_called()
@@ -161,6 +162,7 @@ class TestAssignClass:
obj="obj", context="context", ifc_representation_class="ifc_representation_class", profile_set_usage=None
).should_be_called()
root.is_drawing_annotation("element").should_be_called().will_return(False)
root.get_default_container().should_be_called().will_return("default_container")
root.is_spatial_element("element").should_be_called().will_return(False)
root.is_containable("element").should_be_called().will_return(True)
@@ -181,6 +183,33 @@ class TestAssignClass:
ifc_representation_class="ifc_representation_class",
)
def test_assign_a_class_to_drawing_annotation_without_assigning_container(self, ifc, collector, root):
ifc.get_entity("obj").should_be_called().will_return(None)
root.get_object_name("obj").should_be_called().will_return("name")
ifc.run(
"root.create_entity", ifc_class="ifc_class", predefined_type="predefined_type", name="name"
).should_be_called().will_return("element")
root.set_object_name("obj", "element").should_be_called()
ifc.link("element", "obj").should_be_called()
root.run_geometry_add_representation(
obj="obj", context="context", ifc_representation_class="ifc_representation_class", profile_set_usage=None
).should_be_called()
root.is_drawing_annotation("element").should_be_called().will_return(True)
collector.assign("obj").should_be_called()
subject.assign_class(
ifc,
collector,
root,
obj="obj",
ifc_class="ifc_class",
predefined_type="predefined_type",
should_add_representation=True,
context="context",
ifc_representation_class="ifc_representation_class",
)
def test_not_adding_a_representation_if_requested_no_default_container(self, ifc, collector, root):
ifc.get_entity("obj").should_be_called().will_return(None)
root.get_object_name("obj").should_be_called().will_return("name")
@@ -189,6 +218,7 @@ class TestAssignClass:
).should_be_called().will_return("element")
root.set_object_name("obj", "element").should_be_called()
ifc.link("element", "obj").should_be_called()
root.is_drawing_annotation("element").should_be_called().will_return(False)
root.get_default_container().should_be_called().will_return(None)
collector.assign("obj").should_be_called()
subject.assign_class(