From 343f56b0cd1a0b937265ed1f58c1b88812897eaf Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 25 Sep 2021 19:24:45 +1000 Subject: [PATCH] Minor fix --- src/blenderbim/test/bim/bootstrap.py | 11 +++++++++- .../test/bim/module/root/test_operator.py | 14 ++++++------- .../test/bim/module/sequence/test_operator.py | 1 + .../test/bim/module/void/test_operator.py | 20 ++++++++++--------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/blenderbim/test/bim/bootstrap.py b/src/blenderbim/test/bim/bootstrap.py index f57d35bcde..888e5873a9 100644 --- a/src/blenderbim/test/bim/bootstrap.py +++ b/src/blenderbim/test/bim/bootstrap.py @@ -32,6 +32,9 @@ from mathutils import Vector webbrowser.open = lambda x: True +variables = {"cwd": os.getcwd()} + + class NewFile: @pytest.fixture(autouse=True) def setup(self): @@ -280,7 +283,12 @@ def the_object_name_is_at_location(name, location): ).length < 0.1, f"Object is at {obj_location}" +def the_variable_key_is_value(key, value): + variables[key] = eval(value) + + definitions = { + 'the variable "(.*)" is "(.*)"': the_variable_key_is_value, "an empty IFC project": an_empty_ifc_project, "I add a cube": i_add_a_cube, 'I add a cube of size "([0-9]+)" at "(.*)"': i_add_a_cube_of_size_size_at_location, @@ -324,7 +332,8 @@ definitions = { def run(scenario): keywords = ["Given", "When", "Then", "And", "But"] for line in scenario.split("\n"): - line = line.replace("{cwd}", os.getcwd()) + for key, value in variables.items(): + line = line.replace("{" + key + "}", str(value)) for keyword in keywords: line = line.replace(keyword, "") line = line.strip() diff --git a/src/blenderbim/test/bim/module/root/test_operator.py b/src/blenderbim/test/bim/module/root/test_operator.py index 554b5c7003..a875c6f2d4 100644 --- a/src/blenderbim/test/bim/module/root/test_operator.py +++ b/src/blenderbim/test/bim/module/root/test_operator.py @@ -24,7 +24,7 @@ class TestAssignClass(test.bim.bootstrap.NewFile): def test_assigning_a_class_to_a_cube(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" @@ -37,7 +37,7 @@ class TestAssignClass(test.bim.bootstrap.NewFile): def test_assigning_a_type_class_to_a_cube(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" @@ -51,7 +51,7 @@ class TestAssignClass(test.bim.bootstrap.NewFile): def test_assigning_a_spatial_class_to_a_cube(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_product" to "IfcSpatialElement" And I set "scene.BIMRootProperties.ifc_class" to "IfcBuilding" @@ -65,7 +65,7 @@ class TestAssignClass(test.bim.bootstrap.NewFile): def test_assigning_an_opening_class_to_a_cube(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_product" to "IfcElement" And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement" @@ -80,7 +80,7 @@ class TestAssignClass(test.bim.bootstrap.NewFile): def test_assigning_a_class_to_a_cube_in_a_collection(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And the object "Cube" is placed in the collection "IfcBuildingStorey/My Storey" And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" @@ -94,7 +94,7 @@ class TestCopyClass(test.bim.bootstrap.NewFile): def test_copying_a_wall(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" @@ -118,7 +118,7 @@ class TestCopyClass(test.bim.bootstrap.NewFile): def test_copying_an_opening(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" diff --git a/src/blenderbim/test/bim/module/sequence/test_operator.py b/src/blenderbim/test/bim/module/sequence/test_operator.py index 81fa457ae1..e697071e32 100644 --- a/src/blenderbim/test/bim/module/sequence/test_operator.py +++ b/src/blenderbim/test/bim/module/sequence/test_operator.py @@ -163,6 +163,7 @@ class TestVisualiseWorkScheduleDateRange(test.bim.bootstrap.NewFile): And I set "scene.BIMWorkScheduleProperties.task_time_attributes.get("ScheduleStart").string_value" to "2021-01-02" And I set "scene.BIMWorkScheduleProperties.task_time_attributes.get("ScheduleFinish").string_value" to "2021-01-06" And I press "bim.edit_task_time" + And I add a cube And I rename the object "Cube" to "ToObject" And the object "ToObject" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" diff --git a/src/blenderbim/test/bim/module/void/test_operator.py b/src/blenderbim/test/bim/module/void/test_operator.py index 96cba2d83e..dc824f6c9b 100644 --- a/src/blenderbim/test/bim/module/void/test_operator.py +++ b/src/blenderbim/test/bim/module/void/test_operator.py @@ -24,7 +24,7 @@ class TestAddOpening(test.bim.bootstrap.NewFile): def test_adding_an_opening(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" @@ -44,15 +44,16 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile): def test_removing_an_opening_manually(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" And I add a cube of size "1" at "1,0,0" - And the object "IfcWall/Cube" is selected - And additionally the object "Cube" is selected + And the object "Cube" is selected + And additionally the object "IfcWall/Cube" is selected And I press "bim.add_opening(opening='Cube', obj='IfcWall/Cube')" - And I press "bim.remove_opening(opening_id=97, obj='IfcWall/Cube')" + And the variable "opening_id" is "IfcStore.get_file().by_type('IfcOpeningElement')[0].id()" + And I press "bim.remove_opening(opening_id={opening_id}, obj='IfcWall/Cube')" Then the object "IfcWall/Cube" has no boolean difference by "IfcOpeningElement/Cube" And the object "IfcWall/Cube" is not voided by "Cube" And the object "Cube" is not an IFC element @@ -62,7 +63,7 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile): def test_removing_a_non_dynamic_opening_manually(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" @@ -74,7 +75,8 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile): And I press "bim.switch_representation(ifc_definition_id=86, should_reload=True)" Then the object "IfcWall/Cube" has no boolean difference by "IfcOpeningElement/Cube" And the object "IfcWall/Cube" has "16" vertices - When I press "bim.remove_opening(opening_id=97, obj='IfcWall/Cube')" + And the variable "opening_id" is "IfcStore.get_file().by_type('IfcOpeningElement')[0].id()" + When I press "bim.remove_opening(opening_id={opening_id}, obj='IfcWall/Cube')" Then the object "IfcWall/Cube" has "8" vertices And the object "Cube" is not an IFC element """ @@ -83,7 +85,7 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile): def test_removing_an_opening_using_deletion(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" @@ -101,7 +103,7 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile): def test_removing_an_opening_indirectly_by_deleting_its_building_element(self): return """ Given an empty IFC project - Given I add a cube + And I add a cube When the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class"