mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.project
|
||||
|
||||
|
||||
# NOTE: supported only in IFC4+
|
||||
@@ -29,11 +30,10 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
|
||||
return definitions
|
||||
|
||||
def test_assign_a_declaration(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration",
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file,
|
||||
definitions=[element_type, element_type2],
|
||||
relating_context=library,
|
||||
@@ -42,29 +42,29 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcRelDeclares")) == 1
|
||||
|
||||
def test_doing_nothing_if_the_library_is_already_assigned(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type], relating_context=library
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type], relating_context=library
|
||||
)
|
||||
rel = self.file.by_type("IfcRelDeclares")[0]
|
||||
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type2, element_type3], relating_context=library
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type2, element_type3], relating_context=library
|
||||
)
|
||||
assert len(rel.RelatedDefinitions) == 3
|
||||
|
||||
Reference in New Issue
Block a user