mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -17,12 +17,12 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestAddLibrary(test.bootstrap.IFC4):
|
||||
def test_adding_a_library(self):
|
||||
library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
|
||||
library = ifcopenshell.api.library.add_library(self.file, name="Name")
|
||||
assert library.is_a("IfcLibraryInformation")
|
||||
assert library.Name == "Name"
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestAddReference(test.bootstrap.IFC4):
|
||||
def test_adding_a_reference(self):
|
||||
library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
|
||||
reference = ifcopenshell.api.run("library.add_reference", self.file, library=library)
|
||||
library = ifcopenshell.api.library.add_library(self.file, name="Name")
|
||||
reference = ifcopenshell.api.library.add_reference(self.file, library=library)
|
||||
assert reference.is_a("IfcLibraryReference")
|
||||
ifc2x3 = self.file.schema == "IFC2X3"
|
||||
if ifc2x3:
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestAssignReference(test.bootstrap.IFC4):
|
||||
@@ -26,17 +26,17 @@ class TestAssignReference(test.bootstrap.IFC4):
|
||||
product = self.file.createIfcWall()
|
||||
product2 = self.file.createIfcWall()
|
||||
product3 = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
rel = self.file.by_type("IfcRelAssociatesLibrary")[0]
|
||||
assert rel.RelatedObjects == (product,)
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product2, product3], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product2, product3], reference=reference)
|
||||
assert set(rel.RelatedObjects) == set((product, product2, product3))
|
||||
|
||||
def test_not_assigning_twice(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
product = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
rel = self.file.by_type("IfcRelAssociatesLibrary")[0]
|
||||
assert rel.RelatedObjects == (product,)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import test.bootstrap
|
||||
import datetime
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
import ifcopenshell.util.date
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ class TestEditLibrary(test.bootstrap.IFC4):
|
||||
attributes["Location"] = "Location"
|
||||
attributes["Description"] = "Description"
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"library.edit_library",
|
||||
ifcopenshell.api.library.edit_library(
|
||||
self.file,
|
||||
library=library,
|
||||
attributes=attributes,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestEditReference(test.bootstrap.IFC4):
|
||||
@@ -31,8 +31,7 @@ class TestEditReference(test.bootstrap.IFC4):
|
||||
if self.file.schema != "IFC2X3":
|
||||
attributes["Description"] = "Description"
|
||||
attributes["Language"] = "Language"
|
||||
ifcopenshell.api.run(
|
||||
"library.edit_reference",
|
||||
ifcopenshell.api.library.edit_reference(
|
||||
self.file,
|
||||
reference=reference,
|
||||
attributes=attributes,
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestRemoveLibrary(test.bootstrap.IFC4):
|
||||
def test_removing_a_library(self):
|
||||
library = self.file.createIfcLibraryInformation()
|
||||
ifcopenshell.api.run("library.remove_library", self.file, library=library)
|
||||
ifcopenshell.api.library.remove_library(self.file, library=library)
|
||||
assert len(self.file.by_type("IfcLibraryInformation")) == 0
|
||||
|
||||
def test_removing_a_library_and_all_references(self):
|
||||
@@ -38,7 +38,7 @@ class TestRemoveLibrary(test.bootstrap.IFC4):
|
||||
|
||||
self.file.createIfcRelAssociatesLibrary(GlobalId="foo", RelatingLibrary=library)
|
||||
self.file.createIfcRelAssociatesLibrary(GlobalId="bar", RelatingLibrary=reference1)
|
||||
ifcopenshell.api.run("library.remove_library", self.file, library=library)
|
||||
ifcopenshell.api.library.remove_library(self.file, library=library)
|
||||
assert len(self.file.by_type("IfcLibraryReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestRemoveReference(test.bootstrap.IFC4):
|
||||
def test_removing_a_reference(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
product = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.run("library.remove_reference", self.file, reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.remove_reference(self.file, reference=reference)
|
||||
assert len(self.file.by_type("IfcLibraryReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ class TestUnassignReference(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_reference(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
products = [self.file.createIfcWall() for i in range(3)]
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=products, reference=reference)
|
||||
ifcopenshell.api.run("library.unassign_reference", self.file, products=products[:1], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=products, reference=reference)
|
||||
ifcopenshell.api.library.unassign_reference(self.file, products=products[:1], reference=reference)
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == set(products[1:])
|
||||
|
||||
ifcopenshell.api.run("library.unassign_reference", self.file, products=products[1:], reference=reference)
|
||||
ifcopenshell.api.library.unassign_reference(self.file, products=products[1:], reference=reference)
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == set()
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user