Minor fix

This commit is contained in:
Dion Moult
2021-09-25 19:24:45 +10:00
parent 7155f7ce3d
commit 343f56b0cd
4 changed files with 29 additions and 17 deletions
+10 -1
View File
@@ -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()
@@ -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"
@@ -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"
@@ -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"