mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 14:33:28 +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:
@@ -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