mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
test_feature - add separate non-debug option to save ifc project
Also clean up temp folder before save (met issues when tests were using not updated shading_styles.json)
This commit is contained in:
@@ -9,7 +9,7 @@ Scenario: Duplicate drawing
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -27,7 +27,7 @@ Scenario: Duplicate drawing - without duplicating annotations
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -50,7 +50,7 @@ Scenario: Duplicate drawing - with duplicating annotations
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -73,7 +73,7 @@ Scenario: Create drawing
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -93,7 +93,7 @@ Scenario: Create drawing after deleting a duplicated object
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I duplicate the selected objects
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -112,7 +112,7 @@ Scenario: Activate drawing preserves visibility for non-ifc objects
|
||||
And I add a cube
|
||||
And the object "Cube" is visible
|
||||
And the object "Cube.001" is not visible
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -126,7 +126,7 @@ Scenario: Activate drawing preserves selection
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -143,7 +143,7 @@ Scenario: Remove drawing
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -178,7 +178,7 @@ Scenario: Remove drawing - deleting active drawing
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -193,7 +193,7 @@ Scenario: Add annotation - text
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -207,7 +207,7 @@ Scenario: Add annotation - auto create context if it doesn't exist
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Geometric Representation Contexts" panel
|
||||
And I see "Plan"
|
||||
And I click the "X" after the text "Plan"
|
||||
@@ -228,7 +228,7 @@ Scenario: Create drawing - using shapely fill mode
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I set the "location_hint" property to "My Storey"
|
||||
@@ -244,7 +244,7 @@ Scenario: Create drawing - using shapely fill mode
|
||||
|
||||
Scenario: Add sheet
|
||||
Given an empty IFC project
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Sheets" panel
|
||||
And I click "IMPORT"
|
||||
When I click "ADD"
|
||||
@@ -253,7 +253,7 @@ Scenario: Add sheet
|
||||
|
||||
Scenario: Create sheet
|
||||
Given an empty IFC project
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Sheets" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -270,7 +270,7 @@ Scenario: Add drawing to sheet
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
@@ -295,7 +295,7 @@ Scenario: Create sheet - with a drawing added to it
|
||||
And I set the "Products" property to "IfcElement"
|
||||
And I set the "Class" property to "IfcWall"
|
||||
And I click "Assign IFC Class"
|
||||
And I save sample test files
|
||||
And I save IFC project
|
||||
And I look at the "Drawings" panel
|
||||
And I click "IMPORT"
|
||||
And I click "ADD"
|
||||
|
||||
@@ -21,6 +21,7 @@ import os
|
||||
import types
|
||||
import bpy
|
||||
import pytest
|
||||
import shutil
|
||||
import pprint
|
||||
import traceback
|
||||
import webbrowser
|
||||
@@ -64,6 +65,8 @@ Can be useful for debugging, but has caveats - can't use ``wm.read_homefile``
|
||||
as resets the ``bpy.context`` and some it's members become `None`.
|
||||
"""
|
||||
|
||||
TMP = Path(f"{variables['cwd']}/test/files/temp")
|
||||
|
||||
|
||||
class PanelSpy:
|
||||
def __init__(self, blender_panel: type[bpy.types.Panel]):
|
||||
@@ -325,6 +328,17 @@ def an_empty_ifc_2x3_project():
|
||||
bpy.ops.bim.create_project()
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
|
||||
@given("the Brickschema is stubbed")
|
||||
def the_brickschema_is_stubbed():
|
||||
# This makes things run faster since we don't need to load the entire brick schema
|
||||
@@ -1761,19 +1775,19 @@ def i_fail():
|
||||
@given(parsers.parse("I save sample test files"))
|
||||
@when(parsers.parse("I save sample test files"))
|
||||
@then(parsers.parse("I save sample test files"))
|
||||
def saving_sample_test_files(and_open_in_blender=None):
|
||||
filepath = f"{variables['cwd']}/test/files/temp/sample_test_file"
|
||||
def saving_sample_test_files() -> None:
|
||||
filepath = TMP / "sample_test_file"
|
||||
print(f"Saved to {filepath}")
|
||||
bpy.ops.bim.save_project(filepath=f"{filepath}.ifc", should_save_as=True)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=f"{filepath}.blend")
|
||||
bpy.ops.bim.save_project(filepath=filepath.with_suffix(".ifc").__str__(), should_save_as=True)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=filepath.with_suffix(".blend").__str__())
|
||||
|
||||
|
||||
@given(parsers.parse("I load test blend file"))
|
||||
@when(parsers.parse("I load test blend file"))
|
||||
@then(parsers.parse("I load test blend file"))
|
||||
def opening_sample_test_files_in_blender():
|
||||
filepath = f"{variables['cwd']}/test/files/temp/sample_test_file.blend"
|
||||
bpy.ops.wm.open_mainfile(filepath=filepath, display_file_selector=False)
|
||||
filepath = TMP / "sample_test_file.blend"
|
||||
bpy.ops.wm.open_mainfile(filepath=filepath.__str__(), display_file_selector=False)
|
||||
|
||||
|
||||
# TODO: merge to single fixture with `saving_sample_test_files`; add "and wait"
|
||||
|
||||
Reference in New Issue
Block a user