From 5f7630e527cb5700f056a3e86e3c9ecba43362ba Mon Sep 17 00:00:00 2001 From: Vukas Pajic <83825269+vulevukusej@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:13:15 +0200 Subject: [PATCH] added test for creating new ifcgroups --- .../test/bim/feature/search.feature | 16 +++++++++++--- src/blenderbim/test/bim/test_feature.py | 21 ++++++++++--------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/blenderbim/test/bim/feature/search.feature b/src/blenderbim/test/bim/feature/search.feature index b4070cc05a..8fcf781ff1 100644 --- a/src/blenderbim/test/bim/feature/search.feature +++ b/src/blenderbim/test/bim/feature/search.feature @@ -7,11 +7,21 @@ Scenario: Select all walls And the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" - And I add a new group to IfcSelector - And I add a new query to IfcSelector + And I add a new item to "scene.IfcSelectorProperties.groups" + And I add a new item to "scene.IfcSelectorProperties.groups[0].queries" And I set "scene.IfcSelectorProperties.groups[0].queries[0].selector" to "IFC Class" And I set "scene.IfcSelectorProperties.groups[0].queries[0].active_option" to "124: IfcWall" When I press "bim.filter_model_elements(option='select')" Then the object "IfcWall/Cube" is selected - +Scenario: Add selection to IfcGroup + Given an empty IFC project + And I add a cube + And the object "Cube" is selected + And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" + And I press "bim.assign_class" + And I set "scene.IfcSelectorProperties.selector_query_syntax" to ".IfcWall" + And I set "scene.IfcSelectorProperties.manual_override" to "True" + When I press "bim.add_to_ifc_group(group_name='Walls')" + And I press "bim.load_groups" + Then "scene.BIMGroupProperties.groups[-1].name" is "Walls" diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index b56785404a..579930012f 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -88,7 +88,7 @@ def i_add_an_empty(): @given("I add a sun") -@when("I add an sun") +@when("I add a sun") def i_add_a_sun(): bpy.ops.object.light_add(type="SUN") @@ -98,15 +98,15 @@ def i_add_a_sun(): def i_add_a_material(): bpy.context.active_object.active_material = bpy.data.materials.new("Material") -@given("I add a new group to IfcSelector") -@when("I add a new group to IfcSelector") -def i_add_a_new_collection_item(): - bpy.data.scenes["Scene"].IfcSelectorProperties.groups.add() - -@given("I add a new query to IfcSelector") -@when("I add a new query to IfcSelector") -def i_add_a_new_collection_item(): - bpy.data.scenes["Scene"].IfcSelectorProperties.groups[0].queries.add() + +@given(parsers.parse('I add a new item to "{collection}"')) +@when(parsers.parse('I add a new item to "{collection}"')) +def i_add_a_new_collection_item(collection): + try: + eval(f"bpy.context.{collection}.add()") + except: + assert False, "Collection does not exist" + @given(parsers.parse('the material "{name}" colour is set to "{colour}"')) @when(parsers.parse('the material "{name}" colour is set to "{colour}"')) @@ -485,6 +485,7 @@ def prop_is_value(prop, value): except: pass if not is_value: + print(f"bpy.context.{prop}") actual_value = eval(f"bpy.context.{prop}") assert False, f"Value is {actual_value}"