From e5d1c8cfb9acbd104fbcca4d8b50fda38c80077f Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 8 Mar 2024 16:40:43 +0500 Subject: [PATCH] add test for util.unit.calculate_unit_scale --- src/ifcopenshell-python/test/util/test_unit.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ifcopenshell-python/test/util/test_unit.py b/src/ifcopenshell-python/test/util/test_unit.py index cdf028a222..4b978a6e82 100644 --- a/src/ifcopenshell-python/test/util/test_unit.py +++ b/src/ifcopenshell-python/test/util/test_unit.py @@ -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"