ifc2x3 tests

removed part of test_append_two_type_products_sharing_the_same_material_indirectly_via_a_material_set for ifc2x3 compatibility and removed part is already tested in test_append_two_type_products_sharing_the_same_material_with_properties
This commit is contained in:
Andrej730
2024-05-13 12:32:58 +05:00
parent 3665dda87c
commit a9cba30da6
35 changed files with 395 additions and 262 deletions
@@ -32,3 +32,7 @@ class TestAddActor(test.bootstrap.IFC4):
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
assert actor.is_a() == "IfcOccupant"
assert actor.TheActor == person
class TestAddActorIFC2X3(test.bootstrap.IFC2X3, TestAddActor):
pass
@@ -48,3 +48,7 @@ class TestAddAddress(test.bootstrap.IFC4):
assert postal.Purpose == telecom.Purpose == "OFFICE"
assert postal in organisation.Addresses
assert telecom in organisation.Addresses
class TestAddAddressIFC2X3(test.bootstrap.IFC2X3, TestAddAddress):
pass
@@ -28,7 +28,8 @@ class TestAddApplication(test.bootstrap.IFC4):
assert application.ApplicationFullName == "IfcOpenShell"
assert application.ApplicationIdentifier == "IfcOpenShell"
assert developer.is_a("IfcOrganization")
assert developer.Identification == "IfcOpenShell"
# 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
assert developer[0] == "IfcOpenShell"
assert developer.Name == "IfcOpenShell"
assert (
developer.Description
@@ -40,3 +41,7 @@ class TestAddApplication(test.bootstrap.IFC4):
assert developer.Addresses[0].Purpose == "USERDEFINED"
assert developer.Addresses[0].UserDefinedPurpose == "WEBPAGE"
assert developer.Addresses[0].WWWHomePageURL == "https://ifcopenshell.org"
class TestAddApplicationIFC2X3(test.bootstrap.IFC2X3, TestAddApplication):
pass
@@ -23,5 +23,10 @@ import ifcopenshell.api
class TestAddOrganisation(test.bootstrap.IFC4):
def test_adding_an_organisation(self):
org = ifcopenshell.api.run("owner.add_organisation", self.file, identification="Id", name="Name")
assert org.Identification == "Id"
# 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
assert org[0] == "Id"
assert org.Name == "Name"
class TestAddOrganisationIFC2X3(test.bootstrap.IFC2X3, TestAddOrganisation):
pass
@@ -29,6 +29,11 @@ class TestAddPerson(test.bootstrap.IFC4):
family_name="FamilyName",
given_name="GivenName",
)
assert person.Identification == "Identification"
# 0 IfcPerson Identification(>IFC2X3) / Id (IFC2X3)
assert person[0] == "Identification"
assert person.FamilyName == "FamilyName"
assert person.GivenName == "GivenName"
class TestAddPersonIFC2X3(test.bootstrap.IFC2X3, TestAddPerson):
pass
@@ -27,3 +27,7 @@ class TestAddPersonAndOrganisation(test.bootstrap.IFC4):
person_and_organisation = ifcopenshell.api.run(
"owner.add_person_and_organisation", self.file, person=person, organisation=organisation
)
class TestAddPersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3, TestAddPersonAndOrganisation):
pass
@@ -34,3 +34,7 @@ class TestAddRole(test.bootstrap.IFC4):
assert role.is_a("IfcActorRole")
assert role.Role == "ARCHITECT"
assert organisation.Roles == (role,)
class TestAddRoleIFC2X3(test.bootstrap.IFC2X3, TestAddRole):
pass
@@ -20,7 +20,7 @@ import test.bootstrap
import ifcopenshell.api
class TestAssignProduct(test.bootstrap.IFC4):
class TestAssignActor(test.bootstrap.IFC4):
def test_assigning_an_actor(self):
wall = self.file.createIfcWall()
wall2 = self.file.createIfcWall()
@@ -36,3 +36,7 @@ class TestAssignProduct(test.bootstrap.IFC4):
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)
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
class TestAssignActorIFC2X3(test.bootstrap.IFC2X3, TestAssignActor):
pass
@@ -17,25 +17,36 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import time
import pytest
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.owner.settings
class TestCreateOwnerHistory(test.bootstrap.IFC4):
def test_creating_nothing_if_no_user_or_application_is_available(self):
history = ifcopenshell.api.run("owner.create_owner_history", self.file)
assert history is None
if self.file.schema != "IFC2X3":
history = ifcopenshell.api.run("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)
assert "Please create a user to continue" in str(e.value)
ifcopenshell.api.owner.settings.restore()
def test_creating_a_history_using_a_specified_user_and_application(self):
old_get_user = ifcopenshell.api.owner.settings.get_user
old_get_application = ifcopenshell.api.owner.settings.get_application
ifcopenshell.api.owner.settings.factory_reset()
user = self.file.createIfcPersonAndOrganization()
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)
ifcopenshell.api.owner.settings.get_user = old_get_user
ifcopenshell.api.owner.settings.get_application = old_get_application
ifcopenshell.api.owner.settings.restore()
assert history.is_a("IfcOwnerHistory")
assert history.OwningUser == user
assert history.OwningApplication == application
@@ -45,3 +56,7 @@ class TestCreateOwnerHistory(test.bootstrap.IFC4):
assert history.LastModifyingUser == user
assert history.LastModifyingApplication == application
assert abs(time.time() - history.CreationDate) < 5
class TestCreateOwnerHistoryIFC2X3(test.bootstrap.IFC2X3, TestCreateOwnerHistory):
pass
@@ -52,3 +52,7 @@ class TestEditActor(test.bootstrap.IFC4):
assert actor.Description == "Description"
assert actor.ObjectType == "ObjectType"
assert actor.PredefinedType == "TENANT"
class TestEditActorIFC2X3(test.bootstrap.IFC2X3, TestEditActor):
pass
@@ -53,21 +53,24 @@ class TestEditAddress(test.bootstrap.IFC4):
def test_editing_a_telecom_address(self):
address = self.file.createIfcTelecomAddress()
attributes = {
"Purpose": "OFFICE",
"Description": "Description",
"UserDefinedPurpose": "UserDefinedPurpose",
"TelephoneNumbers": ["Telephone", "Numbers"],
"FacsimileNumbers": ["Facsimile", "Numbers"],
"PagerNumber": "PagerNumber",
"ElectronicMailAddresses": ["Electronic", "Mail", "Addresses"],
"WWWHomePageURL": "WWWHomePageURL",
}
if self.file.schema != "IFC2X3":
attributes["MessagingIDs"] = ["Messaging", "IDs"]
ifcopenshell.api.run(
"owner.edit_address",
self.file,
address=address,
attributes={
"Purpose": "OFFICE",
"Description": "Description",
"UserDefinedPurpose": "UserDefinedPurpose",
"TelephoneNumbers": ["Telephone", "Numbers"],
"FacsimileNumbers": ["Facsimile", "Numbers"],
"PagerNumber": "PagerNumber",
"ElectronicMailAddresses": ["Electronic", "Mail", "Addresses"],
"WWWHomePageURL": "WWWHomePageURL",
"MessagingIDs": ["Messaging", "IDs"],
},
attributes=attributes,
)
assert address.Purpose == "OFFICE"
assert address.Description == "Description"
@@ -77,4 +80,9 @@ class TestEditAddress(test.bootstrap.IFC4):
assert address.PagerNumber == "PagerNumber"
assert address.ElectronicMailAddresses == ("Electronic", "Mail", "Addresses")
assert address.WWWHomePageURL == "WWWHomePageURL"
assert address.MessagingIDs == ("Messaging", "IDs")
if self.file.schema != "IFC2X3":
assert address.MessagingIDs == ("Messaging", "IDs")
class TestEditAddressIFC2X3(test.bootstrap.IFC2X3, TestEditAddress):
pass
@@ -28,11 +28,16 @@ class TestEditOrganisation(test.bootstrap.IFC4):
self.file,
organisation=organisation,
attributes={
"Identification": "Identification",
"Identification" if self.file.schema != "IFC2X3" else "Id": "Identification",
"Name": "Name",
"Description": "Description",
},
)
assert organisation.Identification == "Identification"
# 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
assert organisation[0] == "Identification"
assert organisation.Name == "Name"
assert organisation.Description == "Description"
class TestEditOrganisationIFC2X3(test.bootstrap.IFC2X3, TestEditOrganisation):
pass
@@ -28,7 +28,7 @@ class TestEditPerson(test.bootstrap.IFC4):
self.file,
person=person,
attributes={
"Identification": "Identification",
"Identification" if self.file.schema != "IFC2X3" else "Id": "Identification",
"FamilyName": "FamilyName",
"GivenName": "GivenName",
"MiddleNames": ["Middle", "Names"],
@@ -36,9 +36,14 @@ class TestEditPerson(test.bootstrap.IFC4):
"SuffixTitles": ["Suffix", "Titles"],
},
)
assert person.Identification == "Identification"
# 0 IfcPerson Identification(>IFC2X3) / Id (IFC2X3)
assert person[0] == "Identification"
assert person.FamilyName == "FamilyName"
assert person.GivenName == "GivenName"
assert person.MiddleNames == ("Middle", "Names")
assert person.PrefixTitles == ("Prefix", "Titles")
assert person.SuffixTitles == ("Suffix", "Titles")
class TestEditPersonIFC2X3(test.bootstrap.IFC2X3, TestEditPerson):
pass
@@ -32,3 +32,7 @@ class TestEditRole(test.bootstrap.IFC4):
assert role.Role == "ARCHITECT"
assert role.UserDefinedRole == "UserDefinedRole"
assert role.Description == "Description"
class TestEditRoleIFC2X3(test.bootstrap.IFC2X3, TestEditRole):
pass
@@ -26,3 +26,7 @@ class TestRemoveActor(test.bootstrap.IFC4):
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
ifcopenshell.api.run("owner.remove_actor", self.file, actor=actor)
assert len(self.file.by_type("IfcActor")) == 0
class TestRemoveActorIFC2X3(test.bootstrap.IFC2X3, TestRemoveActor):
pass
@@ -41,3 +41,7 @@ class TestRemoveAddress(test.bootstrap.IFC4):
person.Addresses = [address]
ifcopenshell.api.run("owner.remove_address", self.file, address=address)
assert person.Addresses is None
class TestRemoveAddressIFC2X3(test.bootstrap.IFC2X3, TestRemoveAddress):
pass
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.guid
class TestRemoveOrganisation(test.bootstrap.IFC4):
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)
@@ -82,26 +82,29 @@ class TestRemoveOrganisation(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert document_information.Editors is None
def test_deleting_resource_approval_relationships(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[organisation])
ifcopenshell.api.run("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.createIfcOrganization()
self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[organisation])
ifcopenshell.api.run("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.createIfcOrganization()
self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
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)
assert len(self.file.by_type("IfcApplication")) == 0
class TestRemoveOrganisationIFC4(test.bootstrap.IFC4, TestRemoveOrganisationIFC2X3):
# IfcResourceLevelRelationships were added in IFC4
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)
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)
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)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
@@ -16,12 +16,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import pytest
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.guid
class TestRemovePerson(test.bootstrap.IFC4):
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)
@@ -87,20 +88,23 @@ class TestRemovePerson(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
assert document_information.Editors is None
class TestRemovePersonIFC4(test.bootstrap.IFC4, TestRemovePersonIFC2X3):
# IfcResourceLevelRelationships were added in IFC4
def test_deleting_resource_approval_relationships(self):
person = self.file.createIfcPerson()
self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[person])
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("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.createIfcPerson()
self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[person])
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("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.createIfcPerson()
self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[person])
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.guid
class TestRemovePersonAndOrganisation(test.bootstrap.IFC4):
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)
@@ -39,26 +39,29 @@ class TestRemovePersonAndOrganisation(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
assert document_information.Editors is None
def test_deleting_resource_approval_relationships(self):
user = self.file.createIfcPersonAndOrganization()
self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[user])
ifcopenshell.api.run("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.createIfcPersonAndOrganization()
self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[user])
ifcopenshell.api.run("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.createIfcPersonAndOrganization()
self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[user])
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
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)
assert len(self.file.by_type("IfcOwnerHistory")) == 0
class TestRemovePersonAndOrganisationIFC4(test.bootstrap.IFC4, TestRemovePersonAndOrganisationIFC2X3):
# IfcResourceLevelRelationships were added in IFC4
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)
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)
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)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
@@ -20,7 +20,7 @@ import test.bootstrap
import ifcopenshell.api
class TestRemoveRole(test.bootstrap.IFC4):
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)
@@ -47,20 +47,22 @@ class TestRemoveRole(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
assert person_and_organisation.Roles is None
class TestRemoveRoleIFC4(test.bootstrap.IFC4, TestRemoveRoleIFC2X3):
def test_deleting_resource_approval_relationships(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[organisation])
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("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.createIfcOrganization()
self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[organisation])
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("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.createIfcOrganization()
self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[organisation])
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
@@ -27,3 +27,7 @@ class TestUnassignActor(test.bootstrap.IFC4):
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)
assert len(self.file.by_type("IfcRelAssignsToActor")) == 0
class TestUnassignActorIFC2X3(test.bootstrap.IFC2X3, TestUnassignActor):
pass
@@ -96,3 +96,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
class TestUpdateOwnerHistoryIFC2X3(test.bootstrap.IFC2X3, TestUpdateOwnerHistory):
pass