diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py index 38ae9408e6..0029ac94a0 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py +++ b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py @@ -58,15 +58,20 @@ class Usecase: self.file.remove(rel) if history: ifcopenshell.util.element.remove_deep2(self.file, history) - for rel in self.file.by_type("IfcExternalReferenceRelationship"): - if not rel.RelatingReference: - self.file.remove(rel) - def get_references(self, classification): + if self.file.schema != "IFC2X3": + for rel in self.file.by_type("IfcExternalReferenceRelationship"): + if not rel.RelatingReference: + self.file.remove(rel) + + def get_references(self, classification: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]: results = [] - if not classification.HasReferences: - return results - for reference in classification.HasReferences: - results.append(reference) - results.extend(self.get_references(reference)) + if self.file.schema == "IFC2X3": + for reference in self.file.by_type("IfcClassificationReference"): + if reference.ReferencedSource == classification: + results.append(reference) + else: + for reference in classification.HasReferences: + results.append(reference) + results.extend(self.get_references(reference)) return results diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py index 95c638182a..65c95ca0d1 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py @@ -62,5 +62,17 @@ def add_cost_schedule(file: ifcopenshell.file, name: Optional[str] = None, prede predefined_type=settings["predefined_type"], name=settings["name"], ) - cost_schedule.UpdateDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime") + if file.schema == "IFC2X3": + cost_schedule.UpdateDate = createIfcDateAndTime(file, datetime.now()) + else: + cost_schedule.UpdateDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime") return cost_schedule + + +def createIfcDateAndTime(file: ifcopenshell.file, dt: datetime): + ifc_dt = file.create_entity("IfcDateAndTime") + ifc_dt.DateComponent = file.create_entity( + "IfcCalendarDate", **ifcopenshell.util.date.datetime2ifc(dt, "IfcCalendarDate") + ) + ifc_dt.TimeComponent = file.create_entity("IfcLocalTime", **ifcopenshell.util.date.datetime2ifc(dt, "IfcLocalTime")) + return ifc_dt diff --git a/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py b/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py index c43733f426..e1036e16e3 100644 --- a/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py +++ b/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py @@ -121,3 +121,7 @@ class TestAssignObject(test.bootstrap.IFC4): ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=container) ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element) assert not ifcopenshell.util.element.get_container(subelement, should_get_direct=True) + + +class TestAssignObjectIFC2X3(test.bootstrap.IFC2X3, TestAssignObject): + pass diff --git a/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py b/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py index 64e4fe4fcd..8619275fd7 100644 --- a/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py +++ b/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py @@ -49,3 +49,7 @@ class TestUnassignObject(test.bootstrap.IFC4): ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element) ifcopenshell.api.run("aggregate.unassign_object", self.file, products=[subelement]) assert len(self.file.by_type("IfcRelAggregates")) == 0 + + +class TestUnassignObjectIFC2X3(test.bootstrap.IFC2X3, TestUnassignObject): + pass diff --git a/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py b/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py index b044d32eac..e5a8b98437 100644 --- a/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py +++ b/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py @@ -34,3 +34,7 @@ class TestCopyBoundary(test.bootstrap.IFC4): boundary2 = ifcopenshell.api.run("boundary.copy_boundary", self.file, boundary=boundary) assert boundary2.ConnectionGeometry.is_a("IfcConnectionSurfaceGeometry") assert boundary2.ConnectionGeometry != boundary.ConnectionGeometry + + +class TestCopyBoundaryIFC2X3(test.bootstrap.IFC2X3, TestCopyBoundary): + pass diff --git a/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py b/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py index 7a6f3a0a16..cd3b5ff54b 100644 --- a/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py +++ b/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py @@ -33,3 +33,7 @@ class TestRemoveBoundary(test.bootstrap.IFC4): ifcopenshell.api.run("boundary.remove_boundary", self.file, boundary=boundary) assert not self.file.by_type("IfcRelSpaceBoundary") assert not self.file.by_type("IfcConnectionSurfaceGeometry") + + +class TestRemoveBoundaryIFC2X3(test.bootstrap.IFC2X3, TestRemoveBoundary): + pass diff --git a/src/ifcopenshell-python/test/api/classification/test_add_classification.py b/src/ifcopenshell-python/test/api/classification/test_add_classification.py index 2c80cfb52f..0255e1240c 100644 --- a/src/ifcopenshell-python/test/api/classification/test_add_classification.py +++ b/src/ifcopenshell-python/test/api/classification/test_add_classification.py @@ -32,3 +32,7 @@ class TestAddClassification(test.bootstrap.IFC4): ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject") ifcopenshell.api.run("classification.add_classification", self.file, classification=classification) assert self.file.by_type("IfcClassification")[0].Name == "Name" + + +class TestAddClassificationIFC2X3(test.bootstrap.IFC2X3, TestAddClassification): + pass diff --git a/src/ifcopenshell-python/test/api/classification/test_remove_classification.py b/src/ifcopenshell-python/test/api/classification/test_remove_classification.py index fb3537ddf2..319384306e 100644 --- a/src/ifcopenshell-python/test/api/classification/test_remove_classification.py +++ b/src/ifcopenshell-python/test/api/classification/test_remove_classification.py @@ -47,7 +47,7 @@ class TestRemoveClassification(test.bootstrap.IFC4): def test_removing_a_classification_and_all_of_its_references_when_associated_with_a_resource(self): ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject") result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name") - element = self.file.createIfcMaterial(Name="Material") + element = self.file.create_entity("IfcWall", Name="Wall") ifcopenshell.api.run( "classification.add_reference", self.file, @@ -59,4 +59,9 @@ class TestRemoveClassification(test.bootstrap.IFC4): ifcopenshell.api.run("classification.remove_classification", self.file, classification=result) assert not self.file.by_type("IfcClassification") assert not self.file.by_type("IfcClassificationReference") - assert not self.file.by_type("IfcExternalReferenceRelationship") + if self.file.schema != "IFC2X3": + assert not self.file.by_type("IfcExternalReferenceRelationship") + + +class TestRemoveClassificationIFC2X3(test.bootstrap.IFC2X3, TestRemoveClassification): + pass diff --git a/src/ifcopenshell-python/test/api/context/test_add_context.py b/src/ifcopenshell-python/test/api/context/test_add_context.py index c44ae9d0f9..2a427ef889 100644 --- a/src/ifcopenshell-python/test/api/context/test_add_context.py +++ b/src/ifcopenshell-python/test/api/context/test_add_context.py @@ -75,3 +75,7 @@ class TestAddContext(test.bootstrap.IFC4): self.test_adding_a_2d_context() project = self.file.by_type("IfcProject")[0] assert len(project.RepresentationContexts) == 2 + + +class TestAddContextIFC2X3(test.bootstrap.IFC2X3, TestAddContext): + pass diff --git a/src/ifcopenshell-python/test/api/context/test_edit_context.py b/src/ifcopenshell-python/test/api/context/test_edit_context.py index 1232496b95..210f667f7d 100644 --- a/src/ifcopenshell-python/test/api/context/test_edit_context.py +++ b/src/ifcopenshell-python/test/api/context/test_edit_context.py @@ -58,3 +58,7 @@ class TestEditContext(test.bootstrap.IFC4): assert subcontext.TargetScale == 0.5 assert subcontext.TargetView == "MODEL_VIEW" assert subcontext.UserDefinedTargetView == "UserDefinedTargetView" + + +class TestEditContext(test.bootstrap.IFC2X3, TestEditContext): + pass diff --git a/src/ifcopenshell-python/test/api/context/test_remove_context.py b/src/ifcopenshell-python/test/api/context/test_remove_context.py index f4948dcb4b..682990e154 100644 --- a/src/ifcopenshell-python/test/api/context/test_remove_context.py +++ b/src/ifcopenshell-python/test/api/context/test_remove_context.py @@ -38,16 +38,22 @@ class TestRemoveContext(test.bootstrap.IFC4): subcontext = self.file.createIfcGeometricRepresentationSubcontext() subcontext.ParentContext = context representation = self.file.createIfcRepresentation(ContextOfItems=subcontext) - projected_crs = self.file.createIfcProjectedCRS() - map_conversion = self.file.createIfcMapConversion(SourceCRS=subcontext, TargetCRS=projected_crs) + if self.file.schema != "IFC2X3": + projected_crs = self.file.createIfcProjectedCRS() + map_conversion = self.file.createIfcMapConversion(SourceCRS=subcontext, TargetCRS=projected_crs) ifcopenshell.api.run("context.remove_context", self.file, context=subcontext) assert len(self.file.by_type("IfcGeometricRepresentationSubcontext")) == 0 assert representation in self.file.get_inverse(context) - assert len(self.file.by_type("IfcMapConversion")) == 0 - assert len(self.file.by_type("IfcProjectedCRS")) == 0 + if self.file.schema != "IFC2X3": + assert len(self.file.by_type("IfcMapConversion")) == 0 + assert len(self.file.by_type("IfcProjectedCRS")) == 0 def test_removing_a_context_with_references(self): context = self.file.createIfcGeometricRepresentationContext() representation = self.file.createIfcRepresentation(ContextOfItems=context) ifcopenshell.api.run("context.remove_context", self.file, context=context) assert len([e for e in self.file]) == 0 + + +class TestRemoveContextIFC2X3(test.bootstrap.IFC2X3, TestRemoveContext): + pass diff --git a/src/ifcopenshell-python/test/api/control/test_assign_control.py b/src/ifcopenshell-python/test/api/control/test_assign_control.py index 18670c86e4..e8d63d5d6f 100644 --- a/src/ifcopenshell-python/test/api/control/test_assign_control.py +++ b/src/ifcopenshell-python/test/api/control/test_assign_control.py @@ -48,3 +48,7 @@ class TestAssignControl(test.bootstrap.IFC4): assert len(self.file.by_type("IfcRelAssignsToControl")) == 1 assert relation.RelatingControl == control assert set(relation.RelatedObjects) == set((wall, wall1)) + + +class TestAssignControlIFC2X3(test.bootstrap.IFC2X3, TestAssignControl): + pass diff --git a/src/ifcopenshell-python/test/api/control/test_unassign_control.py b/src/ifcopenshell-python/test/api/control/test_unassign_control.py index c31014f008..c85ee05765 100644 --- a/src/ifcopenshell-python/test/api/control/test_unassign_control.py +++ b/src/ifcopenshell-python/test/api/control/test_unassign_control.py @@ -41,3 +41,7 @@ class TestUnassignControl(test.bootstrap.IFC4): ifcopenshell.api.run("control.unassign_control", self.file, relating_control=control, related_object=wall1) assert len(self.file.by_type("IfcRelAssignsToControl")) == 1 assert relation.RelatedObjects == (wall,) + + +class TestUnassignControlIFC2X3(test.bootstrap.IFC2X3, TestUnassignControl): + pass diff --git a/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py b/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py index 488f10aadc..b2bec35bbf 100644 --- a/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py +++ b/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py @@ -18,6 +18,7 @@ import test.bootstrap import ifcopenshell.api +import ifcopenshell.util.element class TestAddCostItem(test.bootstrap.IFC4): @@ -33,4 +34,8 @@ class TestAddCostItem(test.bootstrap.IFC4): item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule) item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1) assert item2.is_a("IfcCostItem") - assert item2.Nests[0].RelatingObject == item1 + assert ifcopenshell.util.element.get_nest(item2) == item1 + + +class TestAddCostItemIFC2X3(test.bootstrap.IFC2X3, TestAddCostItem): + pass diff --git a/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py b/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py index e02acb0ff6..5646b67601 100644 --- a/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py +++ b/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py @@ -33,3 +33,7 @@ class TestAddCostSchedule(test.bootstrap.IFC4): assert schedule.Name == "Foo" assert schedule.PredefinedType == "USERDEFINED" assert schedule.ObjectType == "FOO" + + +class TestAddCostScheduleIFC2X3(test.bootstrap.IFC2X3, TestAddCostSchedule): + pass diff --git a/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py b/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py index e6768df8b8..96b7a11657 100644 --- a/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py +++ b/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py @@ -45,3 +45,7 @@ class TestRemoveCostItem(test.bootstrap.IFC4): assert not self.file.by_type("IfcCostItem") assert not self.file.by_type("IfcRelAssignsToControl") assert not self.file.by_type("IfcRelNests") + + +class TestRemoveCostItemIFC2X3(test.bootstrap.IFC2X3, TestRemoveCostItem): + pass diff --git a/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py b/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py index 6b88d81a3f..7b2d534653 100644 --- a/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py +++ b/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py @@ -35,3 +35,7 @@ class TestRemoveCostSchedule(test.bootstrap.IFC4): assert not self.file.by_type("IfcCostItem") assert not self.file.by_type("IfcRelNests") assert not self.file.by_type("IfcRelAssignsToControl") + + +class TestRemoveCostSchedule(test.bootstrap.IFC2X3, TestRemoveCostSchedule): + pass diff --git a/src/ifcopenshell-python/test/api/document/test_add_information.py b/src/ifcopenshell-python/test/api/document/test_add_information.py index 4d225e1f39..dcb7eacdb4 100644 --- a/src/ifcopenshell-python/test/api/document/test_add_information.py +++ b/src/ifcopenshell-python/test/api/document/test_add_information.py @@ -30,9 +30,10 @@ class TestAddInformation(test.bootstrap.IFC4): def test_adding_information_to_the_project(self): project = self.file.createIfcProject() element = ifcopenshell.api.run("document.add_information", self.file, parent=None) - rel = element.DocumentInfoForObjects[0] + rel = self.file.by_type("IfcRelAssociatesDocument")[0] assert rel.is_a("IfcRelAssociatesDocument") - assert rel.RelatedObjects[0] == project + assert rel.RelatingDocument == element + assert rel.RelatedObjects == (project,) def test_adding_a_subdocument(self): project = self.file.createIfcProject() @@ -45,3 +46,7 @@ class TestAddInformation(test.bootstrap.IFC4): element2 = ifcopenshell.api.run("document.add_information", self.file, parent=parent) assert element in parent.IsPointer[0].RelatedDocuments assert element2 in parent.IsPointer[0].RelatedDocuments + + +class TestAddInformationIFC2X3(test.bootstrap.IFC2X3, TestAddInformation): + pass diff --git a/src/ifcopenshell-python/test/api/drawing/test_assign_product.py b/src/ifcopenshell-python/test/api/drawing/test_assign_product.py index 78b10e5d76..12e57b7435 100644 --- a/src/ifcopenshell-python/test/api/drawing/test_assign_product.py +++ b/src/ifcopenshell-python/test/api/drawing/test_assign_product.py @@ -37,3 +37,7 @@ class TestAssignProduct(test.bootstrap.IFC4): ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label) assert len(wall.ReferencedBy) == 1 assert wall.ReferencedBy[0].RelatedObjects == (label,) + + +class TestAssignProductIFC2X3(test.bootstrap.IFC2X3, TestAssignProduct): + pass diff --git a/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py b/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py index c0e9e73106..9da51a93e9 100644 --- a/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py +++ b/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py @@ -36,3 +36,7 @@ class TestEditTextLiteral(test.bootstrap.IFC4): assert text.Literal == "Literal" assert text.Path == "RIGHT" assert text.BoxAlignment == "middle" + + +class TestEditTextLiteralIFC2X3(test.bootstrap.IFC2X3, TestEditTextLiteral): + pass diff --git a/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py b/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py index 39cc64ca16..c23e978b1c 100644 --- a/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py +++ b/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py @@ -27,3 +27,7 @@ class TestUnassignProduct(test.bootstrap.IFC4): ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label) ifcopenshell.api.run("drawing.unassign_product", self.file, relating_product=wall, related_object=label) assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0 + + +class TestUnassignProductIFC2X3(test.bootstrap.IFC2X3, TestUnassignProduct): + pass diff --git a/src/ifcopenshell-python/test/api/type/test_map_type_representation.py b/src/ifcopenshell-python/test/api/type/test_map_type_representation.py index a43430a040..a288c60197 100644 --- a/src/ifcopenshell-python/test/api/type/test_map_type_representation.py +++ b/src/ifcopenshell-python/test/api/type/test_map_type_representation.py @@ -49,3 +49,7 @@ class TestMapTypeRepresentations(test.bootstrap.IFC4): assert rep.RepresentationType == "MappedRepresentation" assert rep.Items[0].MappingSource == type.RepresentationMaps[0] assert len(self.file.by_type("IfcShapeRepresentation")) == 2 + + +class TestMapTypeRepresentationsIFC2X3(test.bootstrap.IFC2X3, TestMapTypeRepresentations): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py index b8892fc914..7d6887a893 100644 --- a/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py @@ -39,3 +39,7 @@ class TestAddContextDependentUnit(test.bootstrap.IFC4): assert unit.Dimensions.LuminousIntensityExponent == 7 assert unit.UnitType == "LENGTHUNIT" assert unit.Name == "foobar" + + +class TestAddContextDependentUnitIFC2X3(test.bootstrap.IFC2X3, TestAddContextDependentUnit): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py index 0bfe848e0f..87f3513191 100644 --- a/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py @@ -20,7 +20,7 @@ import test.bootstrap import ifcopenshell.api -class TestAddConversionBasedUnit(test.bootstrap.IFC4): +class TestAddConversionBasedUnitIFC2X3(test.bootstrap.IFC2X3): def test_run(self): unit = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="foot") assert unit.is_a("IfcConversionBasedUnit") @@ -40,6 +40,8 @@ class TestAddConversionBasedUnit(test.bootstrap.IFC4): assert si_unit.Prefix is None assert si_unit.Name == "METRE" + +class TestAddConversionBasedUnitIFC4(test.bootstrap.IFC4, TestAddConversionBasedUnitIFC2X3): def test_adding_a_unit_with_offset(self): unit = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="fahrenheit") assert unit.is_a("IfcConversionBasedUnitWithOffset") diff --git a/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py index af14cf0c2c..47d23505ec 100644 --- a/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py @@ -25,3 +25,7 @@ class TestAddMonetaryUnit(test.bootstrap.IFC4): unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD") assert unit.is_a("IfcMonetaryUnit") assert unit.Currency == "USD" + + +class TestAddMonetaryUnitIFC2X3(test.bootstrap.IFC2X3, TestAddMonetaryUnit): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py index 8ebc7234ad..2c31cef495 100644 --- a/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py @@ -26,3 +26,7 @@ class TestAddSIUnit(test.bootstrap.IFC4): assert unit.UnitType == "LENGTHUNIT" assert unit.Name == "METRE" assert unit.Prefix == "MILLI" + + +class TestAddSIUnitIFC2X3(test.bootstrap.IFC2X3, TestAddSIUnit): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_assign_unit.py b/src/ifcopenshell-python/test/api/unit/test_assign_unit.py index 198e8b362a..c16c423a9a 100644 --- a/src/ifcopenshell-python/test/api/unit/test_assign_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_assign_unit.py @@ -23,8 +23,8 @@ import ifcopenshell.api class TestAssignUnit(test.bootstrap.IFC4): def test_run(self): project = self.file.createIfcProject() - unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="FOO") - unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="BAR") + unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD") + unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="JPY") assignment = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1, unit2]) assert project.UnitsInContext == assignment assert assignment.is_a("IfcUnitAssignment") @@ -33,11 +33,15 @@ class TestAssignUnit(test.bootstrap.IFC4): def test_assign_units_to_an_existing_assignment(self): project = self.file.createIfcProject() - unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="FOO") - unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="BAR") + unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD") + unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="JPY") assignment1 = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1]) assignment2 = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit2]) assert project.UnitsInContext == assignment1 assert assignment1 == assignment2 assert unit1 in assignment1.Units assert unit2 in assignment1.Units + + +class TestAssignUnitIFC2X3(test.bootstrap.IFC2X3, TestAssignUnit): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py b/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py index 026163cf0e..3657fb0511 100644 --- a/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py @@ -31,3 +31,7 @@ class TestEditDerivedUnit(test.bootstrap.IFC4): ) assert unit.UnitType == "USERDEFINED" assert unit.UserDefinedType == "UserDefinedType" + + +class TestEditDerivedUnitIFC2X3(test.bootstrap.IFC2X3, TestEditDerivedUnit): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py b/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py index ef5d10becb..a2d780bfb7 100644 --- a/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py @@ -23,5 +23,9 @@ import ifcopenshell.api class TestEditMonetaryUnit(test.bootstrap.IFC4): def test_run(self): unit = self.file.createIfcMonetaryUnit() - ifcopenshell.api.run("unit.edit_monetary_unit", self.file, unit=unit, attributes={"Currency": "FOO"}) - assert unit.Currency == "FOO" + ifcopenshell.api.run("unit.edit_monetary_unit", self.file, unit=unit, attributes={"Currency": "USD"}) + assert unit.Currency == "USD" + + +class TestEditMonetaryUnitIFC2X3(test.bootstrap.IFC2X3, TestEditMonetaryUnit): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py b/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py index 4aba4a43e3..ffaca2d32b 100644 --- a/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py @@ -20,7 +20,7 @@ import test.bootstrap import ifcopenshell.api -class TestEditNamedUnit(test.bootstrap.IFC4): +class TestEditNamedUnitIFC2X3(test.bootstrap.IFC2X3): def test_edit_context_dependent_unit(self): unit = self.file.createIfcContextDependentUnit() unit.Dimensions = self.file.createIfcDimensionalExponents() @@ -59,6 +59,8 @@ class TestEditNamedUnit(test.bootstrap.IFC4): assert unit.UnitType == "LENGTHUNIT" assert unit.Name == "Name" + +class TestEditNamedUnitIFC4(test.bootstrap.IFC4, TestEditNamedUnitIFC2X3): def test_edit_conversion_based_unit_with_offset(self): unit = self.file.createIfcConversionBasedUnitWithOffset() unit.Dimensions = self.file.createIfcDimensionalExponents() diff --git a/src/ifcopenshell-python/test/api/unit/test_remove_unit.py b/src/ifcopenshell-python/test/api/unit/test_remove_unit.py index c6a885c6bc..c53d66e2eb 100644 --- a/src/ifcopenshell-python/test/api/unit/test_remove_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_remove_unit.py @@ -47,3 +47,7 @@ class TestRemoveUnit(test.bootstrap.IFC4): unit = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="foot") ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit) assert len([e for e in self.file]) == 0 + + +class TestRemoveUnitIFC2X3(test.bootstrap.IFC2X3, TestRemoveUnit): + pass diff --git a/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py b/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py index 0e0d0f71a3..13087d9e00 100644 --- a/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py +++ b/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py @@ -23,8 +23,8 @@ import ifcopenshell.api class TestUnassignUnit(test.bootstrap.IFC4): def test_run(self): project = self.file.createIfcProject() - unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="FOO") - unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="BAR") + unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD") + unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="JPY") assignment = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1, unit2]) ifcopenshell.api.run("unit.unassign_unit", self.file, units=[unit1]) assert unit1 not in assignment.Units @@ -32,11 +32,15 @@ class TestUnassignUnit(test.bootstrap.IFC4): def test_unassigning_the_last_unit(self): project = self.file.createIfcProject() - unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="FOO") + unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD") ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit]) ifcopenshell.api.run("unit.unassign_unit", self.file, units=[unit]) assert project.UnitsInContext is None def test_doing_nothing_if_the_unit_is_not_assigned(self): - unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="FOO") + unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD") assert ifcopenshell.api.run("unit.unassign_unit", self.file, units=[unit]) is None + + +class TestUnassignUnitIFC2X3(test.bootstrap.IFC2X3, TestUnassignUnit): + pass diff --git a/src/ifcopenshell-python/test/api/void/test_add_filling.py b/src/ifcopenshell-python/test/api/void/test_add_filling.py index 46ce089190..c29da2323d 100644 --- a/src/ifcopenshell-python/test/api/void/test_add_filling.py +++ b/src/ifcopenshell-python/test/api/void/test_add_filling.py @@ -43,3 +43,7 @@ class TestAddFilling(test.bootstrap.IFC4): ifcopenshell.api.run("void.add_filling", self.file, opening=opening2, element=door) assert not opening1.HasFillings assert opening2.HasFillings[0].RelatedBuildingElement == door + + +class TestAddFillingIFC2X3(test.bootstrap.IFC2X3, TestAddFilling): + pass diff --git a/src/ifcopenshell-python/test/api/void/test_add_opening.py b/src/ifcopenshell-python/test/api/void/test_add_opening.py index 357cc300fb..4a168eead0 100644 --- a/src/ifcopenshell-python/test/api/void/test_add_opening.py +++ b/src/ifcopenshell-python/test/api/void/test_add_opening.py @@ -77,3 +77,7 @@ class TestAddOpening(test.bootstrap.IFC4): opening.ObjectPlacement = placement ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall) assert opening.ObjectPlacement == placement + + +class TestAddOpeningIFC2X3(test.bootstrap.IFC2X3, TestAddOpening): + pass diff --git a/src/ifcopenshell-python/test/api/void/test_remove_opening.py b/src/ifcopenshell-python/test/api/void/test_remove_opening.py index 6a121a2a61..fd176cb7fc 100644 --- a/src/ifcopenshell-python/test/api/void/test_remove_opening.py +++ b/src/ifcopenshell-python/test/api/void/test_remove_opening.py @@ -47,3 +47,7 @@ class TestRemoveOpening(test.bootstrap.IFC4): assert len(self.file.by_type("IfcRelFillsElement")) == 0 assert wall assert door + + +class TestRemoveOpeningIFC2X3(test.bootstrap.IFC2X3, TestRemoveOpening): + pass