add test for util.unit.calculate_unit_scale

This commit is contained in:
Andrej730
2024-03-08 16:40:43 +05:00
parent 3d5d868812
commit c1bca22638
@@ -22,6 +22,15 @@ import ifcopenshell.api
import ifcopenshell.util.unit as subject
class TestCalculateUnitScale(test.bootstrap.IFC4):
def test_prefix_and_conversion_based_units_are_considered(self):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
length = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="foot")
length.ConversionFactor.UnitComponent.Prefix = "MILLI"
ifcopenshell.api.run("unit.assign_unit", self.file, units=[length])
assert subject.calculate_unit_scale(self.file) == 0.3048 * 0.001
class TestFormatLength(test.bootstrap.IFC4):
def test_run(self):
assert subject.format_length(1, 1, decimal_places=0, unit_system="metric") == "1"