Replace all ifcopenshell.api.run with ifcopenshell.api static functions.

This commit is contained in:
Dion Moult
2024-06-28 12:36:31 +10:00
parent b5d613989e
commit 07060fc769
432 changed files with 4633 additions and 4856 deletions
@@ -17,19 +17,19 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAddActor(test.bootstrap.IFC4):
def test_adding_an_actor(self):
person = self.file.createIfcPerson()
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
assert actor.is_a() == "IfcActor"
assert actor.TheActor == person
def test_adding_an_occupant(self):
person = self.file.createIfcPerson()
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcOccupant", actor=person)
assert actor.is_a() == "IfcOccupant"
assert actor.TheActor == person
@@ -17,18 +17,14 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAddAddress(test.bootstrap.IFC4):
def test_adding_to_a_person(self):
person = self.file.createIfcPerson()
postal = ifcopenshell.api.run(
"owner.add_address", self.file, assigned_object=person, ifc_class="IfcPostalAddress"
)
telecom = ifcopenshell.api.run(
"owner.add_address", self.file, assigned_object=person, ifc_class="IfcTelecomAddress"
)
postal = ifcopenshell.api.owner.add_address(self.file, assigned_object=person, ifc_class="IfcPostalAddress")
telecom = ifcopenshell.api.owner.add_address(self.file, assigned_object=person, ifc_class="IfcTelecomAddress")
assert postal.is_a("IfcPostalAddress")
assert telecom.is_a("IfcTelecomAddress")
assert postal.Purpose == telecom.Purpose == "OFFICE"
@@ -37,11 +33,11 @@ class TestAddAddress(test.bootstrap.IFC4):
def test_adding_to_a_organisation(self):
organisation = self.file.createIfcOrganization()
postal = ifcopenshell.api.run(
"owner.add_address", self.file, assigned_object=organisation, ifc_class="IfcPostalAddress"
postal = ifcopenshell.api.owner.add_address(
self.file, assigned_object=organisation, ifc_class="IfcPostalAddress"
)
telecom = ifcopenshell.api.run(
"owner.add_address", self.file, assigned_object=organisation, ifc_class="IfcTelecomAddress"
telecom = ifcopenshell.api.owner.add_address(
self.file, assigned_object=organisation, ifc_class="IfcTelecomAddress"
)
assert postal.is_a("IfcPostalAddress")
assert telecom.is_a("IfcTelecomAddress")
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAddApplication(test.bootstrap.IFC4):
def test_adding_the_ifcopenshell_application(self):
application = ifcopenshell.api.run("owner.add_application", self.file)
application = ifcopenshell.api.owner.add_application(self.file)
developer = application.ApplicationDeveloper
assert application.Version == ifcopenshell.version
assert application.ApplicationFullName == "IfcOpenShell"
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAddOrganisation(test.bootstrap.IFC4):
def test_adding_an_organisation(self):
org = ifcopenshell.api.run("owner.add_organisation", self.file, identification="Id", name="Name")
org = ifcopenshell.api.owner.add_organisation(self.file, identification="Id", name="Name")
# 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
assert org[0] == "Id"
assert org.Name == "Name"
@@ -17,13 +17,12 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAddPerson(test.bootstrap.IFC4):
def test_adding_a_person(self):
person = ifcopenshell.api.run(
"owner.add_person",
person = ifcopenshell.api.owner.add_person(
self.file,
identification="Identification",
family_name="FamilyName",
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAddPersonAndOrganisation(test.bootstrap.IFC4):
def test_adding(self):
person = self.file.createIfcPerson()
organisation = self.file.createIfcOrganization()
person_and_organisation = ifcopenshell.api.run(
"owner.add_person_and_organisation", self.file, person=person, organisation=organisation
ifcopenshell.api.owner.add_person_and_organisation(
self.file, person=person, organisation=organisation
)
@@ -17,20 +17,20 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAddRole(test.bootstrap.IFC4):
def test_adding_a_role_to_a_person(self):
person = self.file.createIfcPerson()
role = ifcopenshell.api.run("owner.add_role", self.file, assigned_object=person)
role = ifcopenshell.api.owner.add_role(self.file, assigned_object=person)
assert role.is_a("IfcActorRole")
assert role.Role == "ARCHITECT"
assert person.Roles == (role,)
def test_adding_a_role_to_an_organisation(self):
organisation = self.file.createIfcOrganization()
role = ifcopenshell.api.run("owner.add_role", self.file, assigned_object=organisation)
role = ifcopenshell.api.owner.add_role(self.file, assigned_object=organisation)
assert role.is_a("IfcActorRole")
assert role.Role == "ARCHITECT"
assert organisation.Roles == (role,)
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestAssignActor(test.bootstrap.IFC4):
@@ -25,16 +25,16 @@ class TestAssignActor(test.bootstrap.IFC4):
wall = self.file.createIfcWall()
wall2 = self.file.createIfcWall()
actor = self.file.createIfcActor()
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall2)
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall2)
assert actor.IsActingUpon[0].RelatedObjects == (wall, wall2)
def test_not_assigning_twice(self):
wall = self.file.createIfcWall()
actor = self.file.createIfcActor()
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
@@ -26,14 +26,14 @@ import ifcopenshell.api.owner.settings
class TestCreateOwnerHistory(test.bootstrap.IFC4):
def test_creating_nothing_if_no_user_or_application_is_available(self):
if self.file.schema != "IFC2X3":
history = ifcopenshell.api.run("owner.create_owner_history", self.file)
history = ifcopenshell.api.owner.create_owner_history(self.file)
assert history is None
else:
ifcopenshell.api.owner.settings.factory_reset()
# create new file as bootstrap is creating users in ifc2x3 by default
file = ifcopenshell.file(schema="IFC2X3")
with pytest.raises(Exception) as e:
ifcopenshell.api.run("owner.create_owner_history", file)
ifcopenshell.api.owner.create_owner_history(file)
assert "Please create a user to continue" in str(e.value)
ifcopenshell.api.owner.settings.restore()
@@ -44,7 +44,7 @@ class TestCreateOwnerHistory(test.bootstrap.IFC4):
application = self.file.createIfcApplication()
ifcopenshell.api.owner.settings.get_user = lambda x: user
ifcopenshell.api.owner.settings.get_application = lambda x: application
history = ifcopenshell.api.run("owner.create_owner_history", self.file)
history = ifcopenshell.api.owner.create_owner_history(self.file)
ifcopenshell.api.owner.settings.restore()
assert history.is_a("IfcOwnerHistory")
@@ -17,15 +17,14 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestEditActor(test.bootstrap.IFC4):
def test_editing_an_actor(self):
person = self.file.createIfcPerson()
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
ifcopenshell.api.run(
"owner.edit_actor",
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
ifcopenshell.api.owner.edit_actor(
self.file,
actor=actor,
attributes={"Name": "Name", "Description": "Description", "ObjectType": "ObjectType"},
@@ -36,9 +35,8 @@ class TestEditActor(test.bootstrap.IFC4):
def test_editing_an_occupant(self):
person = self.file.createIfcPerson()
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
ifcopenshell.api.run(
"owner.edit_actor",
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcOccupant", actor=person)
ifcopenshell.api.owner.edit_actor(
self.file,
actor=actor,
attributes={
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestEditAddress(test.bootstrap.IFC4):
def test_editing_a_postal_address(self):
address = self.file.createIfcPostalAddress()
ifcopenshell.api.run(
"owner.edit_address",
ifcopenshell.api.owner.edit_address(
self.file,
address=address,
attributes={
@@ -66,8 +65,7 @@ class TestEditAddress(test.bootstrap.IFC4):
if self.file.schema != "IFC2X3":
attributes["MessagingIDs"] = ["Messaging", "IDs"]
ifcopenshell.api.run(
"owner.edit_address",
ifcopenshell.api.owner.edit_address(
self.file,
address=address,
attributes=attributes,
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestEditOrganisation(test.bootstrap.IFC4):
def test_editing_a_organisation(self):
organisation = self.file.createIfcOrganization()
ifcopenshell.api.run(
"owner.edit_organisation",
ifcopenshell.api.owner.edit_organisation(
self.file,
organisation=organisation,
attributes={
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestEditPerson(test.bootstrap.IFC4):
def test_editing_a_person(self):
person = self.file.createIfcPerson()
ifcopenshell.api.run(
"owner.edit_person",
ifcopenshell.api.owner.edit_person(
self.file,
person=person,
attributes={
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestEditRole(test.bootstrap.IFC4):
def test_editing_a_role(self):
role = self.file.createIfcActorRole()
ifcopenshell.api.run(
"owner.edit_role",
ifcopenshell.api.owner.edit_role(
self.file,
role=role,
attributes={"Role": "ARCHITECT", "UserDefinedRole": "UserDefinedRole", "Description": "Description"},
@@ -17,14 +17,14 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestRemoveActor(test.bootstrap.IFC4):
def test_removing_an_actor(self):
person = self.file.createIfcPerson()
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
ifcopenshell.api.run("owner.remove_actor", self.file, actor=actor)
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
ifcopenshell.api.owner.remove_actor(self.file, actor=actor)
assert len(self.file.by_type("IfcActor")) == 0
@@ -17,29 +17,29 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestRemoveAddress(test.bootstrap.IFC4):
def test_removing_an_address(self):
postal = self.file.createIfcPostalAddress()
telecom = self.file.createIfcTelecomAddress()
ifcopenshell.api.run("owner.remove_address", self.file, address=postal)
ifcopenshell.api.run("owner.remove_address", self.file, address=telecom)
ifcopenshell.api.owner.remove_address(self.file, address=postal)
ifcopenshell.api.owner.remove_address(self.file, address=telecom)
assert len(self.file.by_type("IfcAddress")) == 0
def test_ensuring_organisation_cardinality_is_valid(self):
address = self.file.createIfcPostalAddress()
organisation = self.file.createIfcOrganization()
organisation.Addresses = [address]
ifcopenshell.api.run("owner.remove_address", self.file, address=address)
ifcopenshell.api.owner.remove_address(self.file, address=address)
assert organisation.Addresses is None
def test_ensuring_person_cardinality_is_valid(self):
address = self.file.createIfcPostalAddress()
person = self.file.createIfcPerson()
person.Addresses = [address]
ifcopenshell.api.run("owner.remove_address", self.file, address=address)
ifcopenshell.api.owner.remove_address(self.file, address=address)
assert person.Addresses is None
@@ -17,14 +17,14 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
import ifcopenshell.guid
class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_organisation(self):
organisation = self.file.createIfcOrganization()
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganization")) == 0
def test_removing_roles_and_addresses_only_used_by_the_organisation(self):
@@ -33,7 +33,7 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
organisation = self.file.createIfcOrganization()
organisation.Roles = [role]
organisation.Addresses = [address]
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganization")) == 0
assert len(self.file.by_type("IfcActorRole")) == 0
assert len(self.file.by_type("IfcPostalAddress")) == 0
@@ -47,7 +47,7 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
organisation.Addresses = [address]
organisation2.Roles = [role]
organisation2.Addresses = [address]
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganization")) == 1
assert len(self.file.by_type("IfcActorRole")) == 1
assert len(self.file.by_type("IfcPostalAddress")) == 1
@@ -55,37 +55,37 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_deleting_organisation_relationships_as_the_relating_organisation(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcOrganizationRelationship(RelatingOrganization=organisation)
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganizationRelationship")) == 0
def test_deleting_organisation_relationships_as_the_related_organisation(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcOrganizationRelationship(RelatedOrganizations=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganizationRelationship")) == 0
def test_deleting_person_and_organisations(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcPersonAndOrganization(TheOrganization=organisation)
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
def test_deleting_actors(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=organisation)
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcActor")) == 0
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
organisation = self.file.createIfcOrganization()
document_information = self.file.createIfcDocumentInformation(Editors=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert document_information.Editors is None
def test_deleting_an_application(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcApplication(ApplicationDeveloper=organisation)
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcApplication")) == 0
@@ -94,17 +94,17 @@ class TestRemoveOrganisationIFC4(test.bootstrap.IFC4, TestRemoveOrganisationIFC2
def test_deleting_resource_approval_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
@@ -18,14 +18,14 @@
import pytest
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
import ifcopenshell.guid
class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_person(self):
person = self.file.createIfcPerson()
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPerson")) == 0
def test_removing_roles_and_addresses_only_used_by_the_person(self):
@@ -34,7 +34,7 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
person = self.file.createIfcPerson()
person.Roles = [role]
person.Addresses = [address]
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPerson")) == 0
assert len(self.file.by_type("IfcActorRole")) == 0
assert len(self.file.by_type("IfcPostalAddress")) == 0
@@ -48,7 +48,7 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
person.Addresses = [address]
person2.Roles = [role]
person2.Addresses = [address]
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPerson")) == 1
assert len(self.file.by_type("IfcActorRole")) == 1
assert len(self.file.by_type("IfcPostalAddress")) == 1
@@ -56,14 +56,14 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
def test_ensuring_work_controls_should_not_be_left_in_an_invalid_set_cardinality(self):
person = self.file.createIfcPerson()
work_control = self.file.createIfcWorkControl(Creators=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert work_control.Creators is None
def test_ensuring_inventory_should_not_be_left_in_an_invalid_set_cardinality(self):
person = self.file.createIfcPerson()
inventory = self.file.createIfcInventory(ResponsiblePersons=[person])
inventory_id = inventory.id()
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
if self.file.schema != "IFC2X3":
assert inventory.ResponsiblePersons is None
else:
@@ -73,19 +73,19 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
def test_deleting_person_and_organisations(self):
person = self.file.createIfcPerson()
self.file.createIfcPersonAndOrganization(ThePerson=person)
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
def test_deleting_actors(self):
person = self.file.createIfcPerson()
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=person)
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcActor")) == 0
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
person = self.file.createIfcPerson()
document_information = self.file.createIfcDocumentInformation(Editors=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert document_information.Editors is None
@@ -94,17 +94,17 @@ class TestRemovePersonIFC4(test.bootstrap.IFC4, TestRemovePersonIFC2X3):
def test_deleting_resource_approval_relationships(self):
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
@@ -17,32 +17,32 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
import ifcopenshell.guid
class TestRemovePersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_removing(self):
user = self.file.createIfcPersonAndOrganization()
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
def test_deleting_actors(self):
user = self.file.createIfcPersonAndOrganization()
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=user)
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcActor")) == 0
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
user = self.file.createIfcPersonAndOrganization()
document_information = self.file.createIfcDocumentInformation(Editors=[user])
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert document_information.Editors is None
def test_deleting_owner_history(self):
user = self.file.createIfcPersonAndOrganization()
self.file.createIfcOwnerHistory(OwningUser=user)
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcOwnerHistory")) == 0
@@ -51,17 +51,17 @@ class TestRemovePersonAndOrganisationIFC4(test.bootstrap.IFC4, TestRemovePersonA
def test_deleting_resource_approval_relationships(self):
user = self.file.create_entity("IfcPersonAndOrganization")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[user])
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
user = self.file.create_entity("IfcPersonAndOrganization")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[user])
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
user = self.file.create_entity("IfcPersonAndOrganization")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[user])
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
@@ -17,34 +17,34 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestRemoveRoleIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_role(self):
role = self.file.createIfcActorRole()
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
ifcopenshell.api.owner.remove_role(self.file, role=role)
assert len(self.file.by_type("IfcActorRole")) == 0
def test_ensuring_organisation_cardinality_is_valid(self):
role = self.file.createIfcActorRole()
organisation = self.file.createIfcOrganization()
organisation.Roles = [role]
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
ifcopenshell.api.owner.remove_role(self.file, role=role)
assert organisation.Roles is None
def test_ensuring_person_cardinality_is_valid(self):
role = self.file.createIfcActorRole()
person = self.file.createIfcPerson()
person.Roles = [role]
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
ifcopenshell.api.owner.remove_role(self.file, role=role)
assert person.Roles is None
def test_ensuring_person_and_organisation_cardinality_is_valid(self):
role = self.file.createIfcActorRole()
person_and_organisation = self.file.createIfcPersonAndOrganization()
person_and_organisation.Roles = [role]
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
ifcopenshell.api.owner.remove_role(self.file, role=role)
assert person_and_organisation.Roles is None
@@ -52,17 +52,17 @@ class TestRemoveRoleIFC4(test.bootstrap.IFC4, TestRemoveRoleIFC2X3):
def test_deleting_resource_approval_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 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.owner
class TestUnassignActor(test.bootstrap.IFC4):
def test_unassigning_an_actor(self):
wall = self.file.createIfcWall()
actor = self.file.createIfcActor()
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.run("owner.unassign_actor", self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.owner.unassign_actor(self.file, relating_actor=actor, related_object=wall)
assert len(self.file.by_type("IfcRelAssignsToActor")) == 0
@@ -18,7 +18,7 @@
import time
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner
class TestUpdateOwnerHistory(test.bootstrap.IFC4):
@@ -32,7 +32,7 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
ifcopenshell.api.owner.settings.get_application = lambda x: application
element = self.file.createIfcWall()
history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
assert history.is_a("IfcOwnerHistory")
assert element.OwnerHistory == history
assert history.ChangeAction == "ADDED"
@@ -53,10 +53,10 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
ifcopenshell.api.owner.settings.get_application = lambda x: application
element = self.file.createIfcWall()
old_history = ifcopenshell.api.run("owner.create_owner_history", self.file)
old_history = ifcopenshell.api.owner.create_owner_history(self.file)
element.OwnerHistory = old_history
new_history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
new_history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
assert new_history == old_history
assert element.OwnerHistory == new_history
assert new_history.ChangeAction == "MODIFIED"
@@ -78,11 +78,11 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
element = self.file.createIfcWall()
element2 = self.file.createIfcWall()
old_history = ifcopenshell.api.run("owner.create_owner_history", self.file)
old_history = ifcopenshell.api.owner.create_owner_history(self.file)
element.OwnerHistory = old_history
element2.OwnerHistory = old_history
new_history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
new_history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
assert new_history != old_history
assert element.OwnerHistory == new_history
assert new_history.ChangeAction == "MODIFIED"
@@ -95,7 +95,7 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
def test_doing_nothing_if_no_history_can_be_updated(self):
person = self.file.createIfcPerson()
assert ifcopenshell.api.run("owner.update_owner_history", self.file, element=person) == None
assert ifcopenshell.api.owner.update_owner_history(self.file, element=person) == None
class TestUpdateOwnerHistoryIFC2X3(test.bootstrap.IFC2X3, TestUpdateOwnerHistory):