Fix bug where removing addresses and roles could leave other elements in invalid states, "IfcPersonAndOrganization"

This commit is contained in:
Dion Moult
2021-10-01 14:48:44 +10:00
parent 291bb0cd55
commit fe1e30702a
4 changed files with 73 additions and 0 deletions
@@ -9,3 +9,17 @@ class TestRemoveAddress(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_address", self.file, address=postal)
ifcopenshell.api.run("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)
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)
assert person.Addresses is None