mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -18,41 +18,40 @@
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.classification
|
||||
import ifcopenshell.util.classification
|
||||
|
||||
|
||||
class TestRemoveReference(test.bootstrap.IFC4):
|
||||
def test_removing_a_reference(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2],
|
||||
identification="X",
|
||||
name="Foobar",
|
||||
classification=result,
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference", self.file, products=[element, element2], reference=reference
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
assert len(ifcopenshell.util.classification.get_references(element)) == 0
|
||||
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
def test_removing_a_reference_from_a_resource_and_from_a_root(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = self.file.createIfcMaterial()
|
||||
element2 = self.file.createIfcCostValue()
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
if self.file.schema == "IFC2X3":
|
||||
with pytest.raises(TypeError):
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
@@ -61,8 +60,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
)
|
||||
return
|
||||
else:
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
@@ -70,8 +68,8 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
classification=result,
|
||||
)
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference", self.file, products=[element, element2, element3], reference=reference
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2, element3], reference=reference
|
||||
)
|
||||
assert len(ifcopenshell.util.classification.get_references(element)) == 0
|
||||
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
|
||||
@@ -79,13 +77,12 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
def test_retaining_the_reference_if_still_in_use(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
@@ -93,11 +90,11 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
classification=result,
|
||||
)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference", self.file, products=[element, element2], reference=reference
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.run("classification.remove_reference", self.file, products=[element3], reference=reference)
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element3], reference=reference)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user