mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
#2104. Support for adding conversion based units to the project.
This commit is contained in:
@@ -50,6 +50,16 @@ Scenario: Add context dependent unit
|
||||
When I press "bim.add_context_dependent_unit(name='THINGAMAJIGS', unit_type='LENGTHUNIT')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add conversion based unit
|
||||
Given an empty IFC project
|
||||
When I press "bim.add_conversion_based_unit(name='inch')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add conversion based unit with offset
|
||||
Given an empty IFC project
|
||||
When I press "bim.add_conversion_based_unit(name='fahrenheit')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Enable editing unit
|
||||
Given an empty IFC project
|
||||
And the variable "unit" is "{ifc}.by_type('IfcSIUnit')[0].id()"
|
||||
|
||||
@@ -39,7 +39,9 @@ class TestAssignSceneUnits:
|
||||
"unit.add_si_unit", unit_type="VOLUMEUNIT", name="name", prefix="prefix"
|
||||
).should_be_called().will_return("volumeunit")
|
||||
|
||||
ifc.run("unit.assign_unit", units=["lengthunit", "areaunit", "volumeunit"]).should_be_called()
|
||||
ifc.run("unit.add_conversion_based_unit", name="degree").should_be_called().will_return("planeangleunit")
|
||||
|
||||
ifc.run("unit.assign_unit", units=["lengthunit", "areaunit", "volumeunit", "planeangleunit"]).should_be_called()
|
||||
subject.assign_scene_units(ifc, unit)
|
||||
|
||||
def test_creating_and_assigning_imperial_units(self, ifc, unit):
|
||||
@@ -53,7 +55,9 @@ class TestAssignSceneUnits:
|
||||
unit.get_scene_unit_name("volume").should_be_called().will_return("volumename")
|
||||
ifc.run("unit.add_conversion_based_unit", name="volumename").should_be_called().will_return("volumeunit")
|
||||
|
||||
ifc.run("unit.assign_unit", units=["lengthunit", "areaunit", "volumeunit"]).should_be_called()
|
||||
ifc.run("unit.add_conversion_based_unit", name="degree").should_be_called().will_return("planeangleunit")
|
||||
|
||||
ifc.run("unit.assign_unit", units=["lengthunit", "areaunit", "volumeunit", "planeangleunit"]).should_be_called()
|
||||
subject.assign_scene_units(ifc, unit)
|
||||
|
||||
|
||||
@@ -115,6 +119,13 @@ class TestAddContextDependentUnit:
|
||||
assert subject.add_context_dependent_unit(ifc, unit, unit_type="unit_type", name="name") == "unit"
|
||||
|
||||
|
||||
class TestAddConversionBasedUnit:
|
||||
def test_run(self, ifc, unit):
|
||||
ifc.run("unit.add_conversion_based_unit", name="name").should_be_called().will_return("unit")
|
||||
unit.import_units().should_be_called()
|
||||
assert subject.add_conversion_based_unit(ifc, unit, name="name") == "unit"
|
||||
|
||||
|
||||
class TestEnableEditingUnit:
|
||||
def test_run(self, unit):
|
||||
unit.set_active_unit("unit").should_be_called()
|
||||
|
||||
Reference in New Issue
Block a user