mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
A whole bunch of new usecases for managing IFC library information and references
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestAddLibrary(test.bootstrap.IFC4):
|
||||
def test_adding_a_library(self):
|
||||
library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
|
||||
assert library.is_a("IfcLibraryInformation")
|
||||
assert library.Name == "Name"
|
||||
@@ -0,0 +1,10 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
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)
|
||||
assert reference.is_a("IfcLibraryReference")
|
||||
assert reference.ReferencedLibrary == library
|
||||
@@ -0,0 +1,20 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestAssignReference(test.bootstrap.IFC4):
|
||||
def test_assigning_a_reference(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
product = self.file.createIfcWall()
|
||||
product2 = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, product=product, reference=reference)
|
||||
assert reference.LibraryRefForObjects[0].RelatedObjects == (product,)
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, product=product2, reference=reference)
|
||||
assert reference.LibraryRefForObjects[0].RelatedObjects == (product, product2)
|
||||
|
||||
def test_not_assigning_twice(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
product = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, product=product, reference=reference)
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, product=product, reference=reference)
|
||||
assert reference.LibraryRefForObjects[0].RelatedObjects == (product,)
|
||||
@@ -0,0 +1,19 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestEditLibrary(test.bootstrap.IFC4):
|
||||
def test_editing_a_library(self):
|
||||
library = self.file.createIfcLibraryInformation()
|
||||
ifcopenshell.api.run("library.edit_library", self.file, library=library, attributes={
|
||||
"Name": "Name",
|
||||
"Version": "Version",
|
||||
"VersionDate": "VersionDate",
|
||||
"Location": "Location",
|
||||
"Description": "Description",
|
||||
})
|
||||
assert library.Name == "Name"
|
||||
assert library.Version == "Version"
|
||||
assert library.VersionDate == "VersionDate"
|
||||
assert library.Location == "Location"
|
||||
assert library.Description == "Description"
|
||||
@@ -0,0 +1,19 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestEditReference(test.bootstrap.IFC4):
|
||||
def test_editing_a_reference(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
ifcopenshell.api.run("library.edit_reference", self.file, reference=reference, attributes={
|
||||
"Location": "Location",
|
||||
"Identification": "Identification",
|
||||
"Name": "Name",
|
||||
"Description": "Description",
|
||||
"Language": "Language",
|
||||
})
|
||||
assert reference.Location == "Location"
|
||||
assert reference.Identification == "Identification"
|
||||
assert reference.Name == "Name"
|
||||
assert reference.Description == "Description"
|
||||
assert reference.Language == "Language"
|
||||
@@ -0,0 +1,19 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
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)
|
||||
assert len(self.file.by_type("IfcLibraryInformation")) == 0
|
||||
|
||||
def test_removing_a_library_and_all_references(self):
|
||||
library = self.file.createIfcLibraryInformation()
|
||||
reference1 = self.file.createIfcLibraryReference(ReferencedLibrary=library)
|
||||
reference2 = self.file.createIfcLibraryReference(ReferencedLibrary=library)
|
||||
self.file.createIfcRelAssociatesLibrary(GlobalId='foo', RelatingLibrary=library)
|
||||
self.file.createIfcRelAssociatesLibrary(GlobalId='bar', RelatingLibrary=reference1)
|
||||
ifcopenshell.api.run("library.remove_library", self.file, library=library)
|
||||
assert len(self.file.by_type("IfcLibraryReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
@@ -0,0 +1,12 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
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, product=product, reference=reference)
|
||||
ifcopenshell.api.run("library.remove_reference", self.file, reference=reference)
|
||||
assert len(self.file.by_type("IfcLibraryReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
@@ -0,0 +1,12 @@
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestUnassignReference(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_reference(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
product = self.file.createIfcWall()
|
||||
product2 = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, product=product, reference=reference)
|
||||
ifcopenshell.api.run("library.unassign_reference", self.file, product=product, reference=reference)
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
Reference in New Issue
Block a user