From 7d5beb6c808563309c00d5be46bcec2788d8bd48 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 1 Jun 2023 09:50:03 +0500 Subject: [PATCH] Added test to cover 2629172ff --- src/blenderbim/test/bim/feature/pset.feature | 55 ++++++++++++++++++++ src/blenderbim/test/bim/test_feature.py | 20 +++++++ 2 files changed, 75 insertions(+) diff --git a/src/blenderbim/test/bim/feature/pset.feature b/src/blenderbim/test/bim/feature/pset.feature index 0eaaf034f7..c7ad1db8c9 100644 --- a/src/blenderbim/test/bim/feature/pset.feature +++ b/src/blenderbim/test/bim/feature/pset.feature @@ -343,3 +343,58 @@ Scenario: Remove pset - multiple objects And the variable "pset" is "{ifc}.by_type('IfcPropertySet')[-1].id()" When I press "bim.remove_pset(pset_id={pset}, obj='IfcWall/Cube', obj_type='Object')" Then nothing happens + +Scenario: Edit pset length property + Given an empty IFC project + And I press "mesh.add_clever_stair" + And the variable "pset" is "tool.Pset.get_element_pset(tool.Ifc.get_entity(bpy.context.object), 'Pset_StairFlightCommon').id()" + And the variable "si_conversion" is "ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())" + And I press "bim.enable_pset_editing(pset_id={pset}, obj='IfcStairFlight/StairFlight', obj_type='Object')" + + # Testing IfcPositiveLengthMeasure type of prop + Then "active_object.PsetProperties.properties['TreadLength'].metadata.special_type" is "LENGTH" + And "active_object.PsetProperties.properties['TreadLength'].metadata.float_value" is "250" + And "active_object.PsetProperties.properties['TreadLength'].metadata.length_value" is roughly "0.25" + + When I set "active_object.PsetProperties.properties['TreadLength'].metadata.float_value" to "350" + Then "active_object.PsetProperties.properties['TreadLength'].metadata.float_value" is roughly "350" + + When I set "active_object.PsetProperties.properties['TreadLength'].metadata.length_value" to "0.45" + Then "active_object.PsetProperties.properties['TreadLength'].metadata.float_value" is roughly "450" + + # Testing IfcLengthMeasure type of prop + Then "active_object.PsetProperties.properties['NosingLength'].metadata.special_type" is "LENGTH" + And "active_object.PsetProperties.properties['NosingLength'].metadata.float_value" is "0.0" + And "active_object.PsetProperties.properties['NosingLength'].metadata.length_value" is roughly "0.0" + + When I set "active_object.PsetProperties.properties['NosingLength'].metadata.float_value" to "350" + Then "active_object.PsetProperties.properties['NosingLength'].metadata.float_value" is roughly "350" + + When I set "active_object.PsetProperties.properties['NosingLength'].metadata.length_value" to "0.45" + Then "active_object.PsetProperties.properties['NosingLength'].metadata.float_value" is roughly "450" + + When I press "bim.edit_pset(obj='IfcStairFlight/StairFlight', obj_type='Object')" + Then nothing happens + +Scenario: Edit qset length property + Given an empty IFC project + And I press "mesh.add_clever_stair" + And I press "bim.calculate_all_quantities" + And the variable "pset" is "tool.Pset.get_element_pset(tool.Ifc.get_entity(bpy.context.object), 'Qto_StairFlightBaseQuantities').id()" + And the variable "si_conversion" is "ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())" + And I press "bim.enable_pset_editing(pset_id={pset}, obj='IfcStairFlight/StairFlight', obj_type='Object')" + + # Testing Q_LENGTH type of prop + Then "active_object.PsetProperties.properties['Length'].metadata.special_type" is "LENGTH" + And "active_object.PsetProperties.properties['Length'].metadata.float_value" is roughly "2492.57495" + And "active_object.PsetProperties.properties['Length'].metadata.length_value" is roughly "2.49257" + + When I set "active_object.PsetProperties.properties['Length'].metadata.float_value" to "350" + Then "active_object.PsetProperties.properties['Length'].metadata.float_value" is roughly "350" + + When I set "active_object.PsetProperties.properties['Length'].metadata.length_value" to "0.45" + Then "active_object.PsetProperties.properties['Length'].metadata.float_value" is roughly "450" + + When I press "bim.edit_pset(obj='IfcStairFlight/StairFlight', obj_type='Object')" + Then nothing happens + \ No newline at end of file diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index 4100656700..20a48dd259 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -539,6 +539,26 @@ def prop_is_value(prop, value): assert False, f"Value is {actual_value}" +@then(parsers.parse('"{prop}" is roughly "{value}"')) +def prop_is_value(prop, value): + prop = replace_variables(prop) + value = replace_variables(value) + is_value = False + try: + exec(f'assert round(bpy.context.{prop}, 5) == "{value}"') + is_value = True + except: + try: + exec(f"assert round(bpy.context.{prop}, 5) == {value}") + is_value = True + except: + pass + if not is_value: + print(f"bpy.context.{prop}") + actual_value = round(eval(f"bpy.context.{prop}"), 5) + assert False, f"Value is {actual_value}" + + @then(parsers.parse('the object "{name}" has the material "{material}"')) def the_object_name_has_the_material_material(name, material): assert material in [ms.material.name for ms in the_object_name_exists(name).material_slots]