From b9855b289f192b54619a5f8c1a6014bcfd4f6c90 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 24 Aug 2024 22:48:37 +1000 Subject: [PATCH] More qto and spatial tests. Tests can now select items in a UIList. --- src/bonsai/test/bim/feature/qto.feature | 34 ++++++++++++++ src/bonsai/test/bim/feature/spatial.feature | 50 ++++++++++++++++++++- src/bonsai/test/bim/test_feature.py | 19 +++++++- 3 files changed, 100 insertions(+), 3 deletions(-) diff --git a/src/bonsai/test/bim/feature/qto.feature b/src/bonsai/test/bim/feature/qto.feature index d8eaeef40f..30b4f026f5 100644 --- a/src/bonsai/test/bim/feature/qto.feature +++ b/src/bonsai/test/bim/feature/qto.feature @@ -86,3 +86,37 @@ Scenario: Perform quantity take-off - using Blender engine When I look at the "Quantity Sets" panel Then I see "Qto_WallBaseQuantities" And I see "NetVolume" + +Scenario: Manual quantification + Given an empty IFC project + And I add a cube + And the object "Cube" is selected + And I look at the "Class" panel + And I set the "Products" property to "IfcElement" + And I set the "Class" property to "IfcWall" + And I click "Assign IFC Class" + And I look at the "Manual Quantification" panel + When I set the "qto_name" property to "Foo" + And I set the "prop_name" property to "Bar" + And I click "Calculate Single Quantity" + When I look at the "Quantity Sets" panel + Then I see "Foo" + And I see "Bar" + +Scenario: Manual quantification - set an engine and function + Given an empty IFC project + And I add a cube + And the object "Cube" is selected + And I look at the "Class" panel + And I set the "Products" property to "IfcElement" + And I set the "Class" property to "IfcWall" + And I click "Assign IFC Class" + And I look at the "Manual Quantification" panel + And I set the "Calculator" property to "IfcOpenShell" + And I set the "Function" property to "Volume: Net Volume" + When I set the "qto_name" property to "Foo" + And I set the "prop_name" property to "Bar" + And I click "Calculate Single Quantity" + When I look at the "Quantity Sets" panel + Then I see "Foo" + And I see "Bar" diff --git a/src/bonsai/test/bim/feature/spatial.feature b/src/bonsai/test/bim/feature/spatial.feature index d0ece452a8..c7b932c308 100644 --- a/src/bonsai/test/bim/feature/spatial.feature +++ b/src/bonsai/test/bim/feature/spatial.feature @@ -101,8 +101,6 @@ Scenario: Select similar container When I press "bim.select_similar_container" Then nothing happens -#HERE STARTS TESTS FOR SPATIAL TOOL - Scenario: Execute generate space from cursor position Given an empty IFC project When I press "bim.generate_space" @@ -126,3 +124,51 @@ Scenario: Execute toggle space visibility And I press "bim.assign_class(ifc_class='IfcSpace', predefined_type='SPACE')" When I press "bim.toggle_space_visibility" Then nothing happens + +Scenario: Spatial decomposition - see panel + Given an empty IFC project + When I look at the "Spatial Decomposition" panel + Then the "BIM_UL_containers_manager" list has 4 items + And I don't see the "BIM_UL_elements" list + +Scenario: Isolate spatial container + Given an empty IFC project + And I look at the "Spatial Decomposition" panel + When I select the "My Site" item in the "BIM_UL_containers_manager" list + And I click "Isolate" + Then nothing happens + +Scenario: Show spatial container + Given an empty IFC project + And I look at the "Spatial Decomposition" panel + When I select the "My Site" item in the "BIM_UL_containers_manager" list + And I click "HIDE_OFF" + Then nothing happens + +Scenario: Hide spatial container + Given an empty IFC project + And I look at the "Spatial Decomposition" panel + When I select the "My Site" item in the "BIM_UL_containers_manager" list + And I click "HIDE_ON" + Then nothing happens + +Scenario: Select spatial container + Given an empty IFC project + And I look at the "Spatial Decomposition" panel + When I select the "My Site" item in the "BIM_UL_containers_manager" list + And I click "OBJECT_DATA" + Then the object "IfcSite/My Site" is selected + +Scenario: Delete spatial container + Given an empty IFC project + And I look at the "Spatial Decomposition" panel + When I select the "My Building" item in the "BIM_UL_containers_manager" list + And I click "X" + Then the "BIM_UL_containers_manager" list has 2 items + +Scenario: Add spatial container + Given an empty IFC project + And I look at the "Spatial Decomposition" panel + And I set the "subelement_class" property to "IfcExternalSpatialElement" + When I click "ADD" + Then the "BIM_UL_containers_manager" list has 5 items diff --git a/src/bonsai/test/bim/test_feature.py b/src/bonsai/test/bim/test_feature.py index c96ccc743b..23d28a8805 100644 --- a/src/bonsai/test/bim/test_feature.py +++ b/src/bonsai/test/bim/test_feature.py @@ -310,7 +310,7 @@ def i_set_the_prop_property_to_value(prop, value): elif spied_prop["prop_type"] == "INTEGER": setattr(spied_prop["props"], spied_prop["name"], int(value)) elif spied_prop["prop_type"] == "ENUM": - enum_identifier = [i for i in spied_prop["enum_items"] if i[1] == value] + enum_identifier = [i for i in spied_prop["enum_items"] if i is not None and i[1] == value] if not enum_identifier: assert False, f"Could not find value {value} in enum {spied_prop['enum_items']}" setattr(spied_prop["props"], spied_prop["name"], enum_identifier[0][0]) @@ -333,6 +333,22 @@ def the_name_list_has_total_items(name, total): assert False, f"List {name} not found in {panel_spy.spied_lists}" +@when(parsers.parse('I select the "{item_name}" item in the "{list_name}" list')) +def i_select_the_item_name_item_in_the_list_name_list(item_name, list_name): + panel_spy.refresh_spy() + for spied_list in panel_spy.spied_lists: + if list_name == spied_list["listtype_name"]: + item_names = [] + for i, item in enumerate(getattr(spied_list["dataptr"], spied_list["propname"])): + item_names.append(item.name) + if item.name == item_name: + setattr(spied_list["active_dataptr"], spied_list["active_propname"], i) + panel_spy.is_spy_dirty = True + return + assert False, f"Could not find item {item_name} in {item_names}" + assert False, f"List {list_name} not found in {panel_spy.spied_lists}" + + @when("I load a new pset template file") def i_load_a_new_pset_template_file(): IfcStore.pset_template_path = bpy.context.scene.BIMPsetTemplateProperties.pset_template_files @@ -519,6 +535,7 @@ def i_deselect_all_objects(): @given(parsers.parse('the object "{name}" is selected')) @when(parsers.parse('the object "{name}" is selected')) +@then(parsers.parse('the object "{name}" is selected')) def the_object_name_is_selected(name): i_deselect_all_objects() additionally_the_object_name_is_selected(name)