mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
more tests for ifc2x3
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -31,3 +31,7 @@ class TestEditDerivedUnit(test.bootstrap.IFC4):
|
||||
)
|
||||
assert unit.UnitType == "USERDEFINED"
|
||||
assert unit.UserDefinedType == "UserDefinedType"
|
||||
|
||||
|
||||
class TestEditDerivedUnitIFC2X3(test.bootstrap.IFC2X3, TestEditDerivedUnit):
|
||||
pass
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user