Added test to cover 2629172ff

This commit is contained in:
Andrej730
2023-06-01 09:50:03 +05:00
parent ecc0263062
commit 7d5beb6c80
2 changed files with 75 additions and 0 deletions
@@ -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
+20
View File
@@ -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]