Support auto detection of unit type when adding imperial units

This commit is contained in:
Dion Moult
2021-10-14 12:44:13 +11:00
parent 464b0c2ebc
commit 1fa1a9e3d3
8 changed files with 216 additions and 0 deletions
@@ -0,0 +1,31 @@
import test.bootstrap
import ifcopenshell.api
class TestRemoveUnit(test.bootstrap.IFC4):
def test_remove_a_single_unit(self):
unit = self.file.createIfcContextDependentUnit()
ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit)
assert len(self.file.by_type("IfcContextDependentUnit")) == 0
def test_remove_the_only_assigned_unit(self):
self.file.createIfcProject()
unit = self.file.createIfcContextDependentUnit()
ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit)
assert len(self.file.by_type("IfcContextDependentUnit")) == 0
assert len(self.file.by_type("IfcUnitAssignment")) == 0
def test_remove_an_assigned_unit(self):
self.file.createIfcProject()
unit1 = self.file.createIfcContextDependentUnit()
unit2 = self.file.createIfcSIUnit()
assignment = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1, unit2])
ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit1)
assert len(self.file.by_type("IfcContextDependentUnit")) == 0
assert assignment.Units == (unit2,)
def test_removing_a_unit_deeply(self):
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