mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
test_feature - use common prompts for loading/saving temp projects
This commit is contained in:
@@ -504,10 +504,12 @@ class Project(bonsai.core.tool.Project):
|
||||
normals.append((v1, d1.cross(d2).normalized()))
|
||||
return normals
|
||||
|
||||
TEMP_PROJECT_PATH = Path.cwd() / "test/files/temp/test_project.ifc"
|
||||
|
||||
@classmethod
|
||||
def save_test_project(cls) -> None:
|
||||
TMP = Path.cwd() / "test/files/temp"
|
||||
# Clean up previous test project.
|
||||
if TMP.exists():
|
||||
shutil.rmtree(TMP)
|
||||
bpy.ops.bim.save_project(filepath=(TMP / "test_project.ifc").__str__(), should_save_as=True)
|
||||
tmp = cls.TEMP_PROJECT_PATH.parent
|
||||
# Clean up previous test project to avoid conflicts with non-updated assets.
|
||||
if tmp.exists():
|
||||
shutil.rmtree(tmp)
|
||||
bpy.ops.bim.save_project(filepath=cls.TEMP_PROJECT_PATH.__str__(), should_save_as=True)
|
||||
|
||||
@@ -352,9 +352,8 @@ Scenario: Override duplicate move - copying a coloured representation
|
||||
And the variable "style" is "{ifc}.by_type('IfcSurfaceStyle')[0].id()"
|
||||
And I press "bim.assign_style_to_selected(style_id={style})"
|
||||
When I duplicate the selected objects
|
||||
And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc', should_start_fresh_session=False)"
|
||||
And I save IFC project
|
||||
And I load previously saved IFC project
|
||||
Then the material "Style" colour is "1,0,0,1"
|
||||
And the object "IfcWall/Cube" has the material "Style"
|
||||
And the object "IfcWall/Cube.001" has the material "Style"
|
||||
|
||||
@@ -833,20 +833,21 @@ Scenario: Unlink IFC
|
||||
|
||||
Scenario: Export IFC - blank project
|
||||
Given an empty IFC project
|
||||
When I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
When I save IFC project
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Export IFC - with basic contents
|
||||
Given an empty Blender session
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
|
||||
When I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/temp/export.ifc"
|
||||
When I save IFC project
|
||||
Then "scene.BIMProperties.ifc_file" is "{temp_project_path}"
|
||||
|
||||
Scenario: Export IFC - with basic contents and saving as another file
|
||||
Given an empty Blender session
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
|
||||
When I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc', should_save_as=True)"
|
||||
Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/temp/export.ifc"
|
||||
When I save IFC project
|
||||
When I press "bim.save_project(filepath='{temp_project_path}', should_save_as=True)"
|
||||
Then "scene.BIMProperties.ifc_file" is "{temp_project_path}"
|
||||
|
||||
Scenario: Export IFC - with basic contents and saving as IfcJSON where import is not supported
|
||||
Given an empty Blender session
|
||||
@@ -877,26 +878,23 @@ Scenario: Export IFC - with deleted objects synchronised
|
||||
And the object "IfcBuildingStorey/My Storey" is selected
|
||||
And I set the "is_locked" property to "FALSE"
|
||||
And I delete the selected objects
|
||||
And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And I save IFC project
|
||||
And I load previously saved IFC project
|
||||
Then the object "IfcBuildingStorey/My Storey" does not exist
|
||||
|
||||
Scenario: Export IFC - with moved object location synchronised
|
||||
Given an empty IFC project
|
||||
When the object "IfcBuildingStorey/My Storey" is moved to "0,0,1"
|
||||
And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And I save IFC project
|
||||
And I load previously saved IFC project
|
||||
Then the object "IfcBuildingStorey/My Storey" is at "0,0,1"
|
||||
|
||||
Scenario: Export IFC - with moved grid axis location synchronised
|
||||
Given an empty IFC project
|
||||
And I press "mesh.add_grid"
|
||||
When the object "IfcGridAxis/01" is moved to "1,0,0"
|
||||
And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And I save IFC project
|
||||
And I load previously saved IFC project
|
||||
Then the object "IfcGridAxis/01" bottom left corner is at "1,-2,0"
|
||||
|
||||
Scenario: Export IFC - with changed object scale ignored
|
||||
@@ -909,7 +907,6 @@ Scenario: Export IFC - with changed object scale ignored
|
||||
And I click "Assign IFC Class"
|
||||
And the object "IfcWall/Cube" is selected
|
||||
When the object "IfcWall/Cube" is scaled to "2"
|
||||
And I press "bim.save_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And an empty Blender session is started
|
||||
And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')"
|
||||
And I save IFC project
|
||||
And I load previously saved IFC project
|
||||
Then the object "IfcWall/Cube" dimensions are "2,2,2"
|
||||
|
||||
@@ -50,6 +50,7 @@ variables = {
|
||||
"ifc": "tool.Ifc.get()",
|
||||
"pset_ifc": "IfcStore.pset_template_file",
|
||||
"classification_ifc": "IfcStore.classification_file",
|
||||
"temp_project_path": tool.Project.TEMP_PROJECT_PATH.as_posix(),
|
||||
}
|
||||
|
||||
# Monkey-patch webbrowser opening since we want to test headlessly
|
||||
@@ -330,15 +331,19 @@ def an_empty_ifc_2x3_project():
|
||||
bpy.ops.bim.create_project()
|
||||
|
||||
|
||||
@given(parsers.parse("I load previously saved IFC project"))
|
||||
@when(parsers.parse("I load previously saved IFC project"))
|
||||
@then(parsers.parse("I load previously saved IFC project"))
|
||||
def load_previously_saved_ifc_project() -> None:
|
||||
filepath = tool.Project.TEMP_PROJECT_PATH
|
||||
bpy.ops.bim.load_project(filepath=filepath.__str__())
|
||||
|
||||
|
||||
@given(parsers.parse("I save IFC project"))
|
||||
@when(parsers.parse("I save IFC project"))
|
||||
@then(parsers.parse("I save IFC project"))
|
||||
def saving_ifc_project() -> None:
|
||||
# Remove old temp files to avoid conflicts with non-updated assets.
|
||||
if TMP.exists():
|
||||
shutil.rmtree(TMP)
|
||||
filepath = TMP / "test_project.ifc"
|
||||
bpy.ops.bim.save_project(filepath=filepath.__str__(), should_save_as=True)
|
||||
tool.Project.save_test_project()
|
||||
|
||||
|
||||
@given("the Brickschema is stubbed")
|
||||
|
||||
Reference in New Issue
Block a user