diff --git a/.gitignore b/.gitignore index 371a4bba9b..c95faa97a1 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,9 @@ src/ifcopenshell-python/test/build # blenderbim libs src/blenderbim/blenderbim/libs +# blenderbim test temp files +src/blenderbim/test/files/temp + # ifcopenshell swig and compiled files src/ifcopenshell-python/ifcopenshell/_ifcopenshell_wrapper.so src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.py diff --git a/src/blenderbim/test/bim/feature/geometry.feature b/src/blenderbim/test/bim/feature/geometry.feature index 40bc91439f..49bd1b548e 100644 --- a/src/blenderbim/test/bim/feature/geometry.feature +++ b/src/blenderbim/test/bim/feature/geometry.feature @@ -87,7 +87,7 @@ Scenario: Switch representation - current edited representation is updated prior And I press "bim.switch_representation(ifc_definition_id={representation}, should_reload=True)" And the variable "representation" is "[r for r in {ifc}.by_type('IfcShapeRepresentation') if r.RepresentationType=='Annotation2D'][0].id()" And I press "bim.switch_representation(ifc_definition_id={representation}, should_reload=True)" - When I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + When I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" Then the object "IfcWall/Cube" dimensions are "4,4,0" Scenario: Switch representation - current edited representation is discarded if switching to a box @@ -101,7 +101,7 @@ Scenario: Switch representation - current edited representation is discarded if And I press "bim.switch_representation(obj='IfcWall/Cube', ifc_definition_id={representation}, should_reload=True)" And the variable "representation" is "{ifc}.by_type('IfcShapeRepresentation')[0].id()" And I press "bim.switch_representation(obj='IfcWall/Cube', ifc_definition_id={representation}, should_reload=True)" - When I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + When I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" Then the object "IfcWall/Cube" dimensions are "2,2,2" Scenario: Switch representation - existing Blender modifiers must be purged @@ -316,9 +316,9 @@ Scenario: Override duplicate move - copying a coloured representation And the object "IfcWall/Cube" is selected And the material "Material" colour is set to "1,0,0,1" When I press "object.duplicate_move" - And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" Then the material "Material" colour is "1,0,0,1" And the object "IfcWall/Cube" has the material "Material" And the object "IfcWall/Cube.001" has the material "Material" diff --git a/src/blenderbim/test/bim/feature/patch.feature b/src/blenderbim/test/bim/feature/patch.feature index e49065bb30..87e44d50ef 100644 --- a/src/blenderbim/test/bim/feature/patch.feature +++ b/src/blenderbim/test/bim/feature/patch.feature @@ -5,21 +5,21 @@ Scenario: Execute IFC Patch - file in memory Given an empty IFC project And I set "scene.BIMPatchProperties.ifc_patch_recipes" to "OffsetObjectPlacements" And I set "scene.BIMPatchProperties.should_load_from_memory" to "True" - And I set "scene.BIMPatchProperties.ifc_patch_output" to "{cwd}/test/files/basic-patched.ifc" + And I set "scene.BIMPatchProperties.ifc_patch_output" to "{cwd}/test/files/temp/basic-patched.ifc" And I set "scene.BIMPatchProperties.ifc_patch_args" to "[123454321,0,0,0]" When I press "bim.execute_ifc_patch(use_json_for_args=True)" - Then the file "{cwd}/test/files/basic-patched.ifc" should contain "123454321" + Then the file "{cwd}/test/files/temp/basic-patched.ifc" should contain "123454321" Scenario: Execute IFC Patch - file from disk Given an empty IFC project And I set "scene.BIMPatchProperties.ifc_patch_recipes" to "OffsetObjectPlacements" And I set "scene.BIMPatchProperties.ifc_patch_input" to "{cwd}/test/files/basic.ifc" - And I set "scene.BIMPatchProperties.ifc_patch_output" to "{cwd}/test/files/basic-patched.ifc" + And I set "scene.BIMPatchProperties.ifc_patch_output" to "{cwd}/test/files/temp/basic-patched.ifc" And I set "scene.BIMPatchProperties.ifc_patch_args" to "[123454321,0,0,0]" When I press "bim.execute_ifc_patch(use_json_for_args=True)" - Then the file "{cwd}/test/files/basic-patched.ifc" should contain "123454321" + Then the file "{cwd}/test/files/temp/basic-patched.ifc" should contain "123454321" Scenario: Run migrate patch Given an empty Blender session - When I press "bim.run_migrate_patch(infile='{cwd}/test/files/ifc2x3.ifc', outfile='{cwd}/test/files/ifc2x3-migrated.ifc', schema='IFC4')" - Then the file "{cwd}/test/files/ifc2x3-migrated.ifc" should contain "IFC4" + When I press "bim.run_migrate_patch(infile='{cwd}/test/files/ifc2x3.ifc', outfile='{cwd}/test/files/temp/ifc2x3-migrated.ifc', schema='IFC4')" + Then the file "{cwd}/test/files/temp/ifc2x3-migrated.ifc" should contain "IFC4" diff --git a/src/blenderbim/test/bim/feature/project.feature b/src/blenderbim/test/bim/feature/project.feature index efe3a539e1..d7ea9d5849 100644 --- a/src/blenderbim/test/bim/feature/project.feature +++ b/src/blenderbim/test/bim/feature/project.feature @@ -359,67 +359,67 @@ Scenario: Unlink IFC Scenario: Export IFC - blank project Given an empty IFC project - When I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + When I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" 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 "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" - Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/export.ifc" + When I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" + Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/temp/export.ifc" 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 "export_ifc.bim(filepath='{cwd}/test/files/export.ifc', should_save_as=True)" - Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/export.ifc" + When I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc', should_save_as=True)" + Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/temp/export.ifc" Scenario: Export IFC - with basic contents and saving as IfcJSON where import is not supported Given an empty Blender session And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')" - When I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifcjson', should_save_as=True)" + When I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifcjson', should_save_as=True)" Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/basic.ifc" Scenario: Export IFC - with basic contents and round-tripping an IfcZip Given an empty Blender session And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')" - When I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifczip', should_save_as=True)" + When I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifczip', should_save_as=True)" Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/basic.ifc" When an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifczip')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifczip')" Then the object "IfcProject/My Project" is an "IfcProject" Scenario: Export IFC - with basic contents and saving as a relative path Given an empty Blender session And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')" - When I press "wm.save_mainfile(filepath='{cwd}/test/files/export.blend')" - And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc', use_relative_path=True)" + When I press "wm.save_mainfile(filepath='{cwd}/test/files/temp/export.blend')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc', use_relative_path=True)" Then "scene.BIMProperties.ifc_file" is "export.ifc" Scenario: Export IFC - with deleted objects synchronised Given an empty IFC project When the object "IfcBuildingStorey/My Storey" is selected And I press "object.delete" - And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" 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 "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" 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 "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" Then the object "IfcGridAxis/01" bottom left corner is at "1,-2,0" Scenario: Export IFC - with changed spatial container synchronised @@ -427,9 +427,9 @@ Scenario: Export IFC - with changed spatial container synchronised And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')" Then the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Ground Floor" When the object "IfcSlab/Slab" is placed in the collection "IfcBuildingStorey/Level 1" - And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" Then the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Level 1" Scenario: Export IFC - with changed object scale synchronised @@ -440,9 +440,9 @@ Scenario: Export IFC - with changed object scale synchronised And I press "bim.assign_class" And the object "IfcWall/Cube" is selected When the object "IfcWall/Cube" is scaled to "2" - And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" Then the object "IfcWall/Cube" dimensions are "4,4,4" Scenario: Export IFC - with changed style colour synchronised @@ -454,9 +454,9 @@ Scenario: Export IFC - with changed style colour synchronised And I press "bim.assign_class" And the object "IfcWall/Cube" is selected When the material "Material" colour is set to "1,0,0,1" - And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" Then the material "Material" colour is "1,0,0,1" Scenario: Export IFC - with changed style element synchronised @@ -469,7 +469,7 @@ Scenario: Export IFC - with changed style element synchronised And the object "IfcWall/Cube" is selected When I add a material And the material "Material.001" colour is set to "1,0,0,1" - And I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifc')" + And I press "export_ifc.bim(filepath='{cwd}/test/files/temp/export.ifc')" And an empty Blender session is started - And I press "bim.load_project(filepath='{cwd}/test/files/export.ifc')" + And I press "bim.load_project(filepath='{cwd}/test/files/temp/export.ifc')" Then the material "Material.001" colour is "1,0,0,1" diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index faf0f830b3..a59af93edd 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -722,7 +722,7 @@ def run_test_code(): @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/sample_test_file" + filepath = f"{variables['cwd']}/test/files/temp/sample_test_file" blend_filepath = f"{filepath}.blend" bpy.ops.export_ifc.bim(filepath=f"{filepath}.ifc", should_save_as=True) bpy.ops.wm.save_as_mainfile(filepath=f"{filepath}.blend") @@ -734,7 +734,7 @@ def saving_sample_test_files(and_open_in_blender=None): @then(parsers.parse("I save sample test files and open in blender")) def saving_sample_test_files_and_open_in_blender(): saving_sample_test_files() - filepath = f"{variables['cwd']}/test/files/sample_test_file.blend" + filepath = f"{variables['cwd']}/test/files/temp/sample_test_file.blend" import subprocess subprocess.Popen([bpy.app.binary_path, f"{filepath}"]) diff --git a/src/blenderbim/test/tool/test_debug.py b/src/blenderbim/test/tool/test_debug.py index 099a6ccd54..c54aea8118 100644 --- a/src/blenderbim/test/tool/test_debug.py +++ b/src/blenderbim/test/tool/test_debug.py @@ -34,16 +34,20 @@ class TestImplementsTool(NewFile): class TestAddSchemaIdentifier(NewFile): def test_run(self): cwd = os.path.dirname(os.path.realpath(__file__)) - schema = subject.load_express(os.path.join(cwd, "..", "files", "test.exp")) + schema_path = os.path.join(cwd, "..", "files", "test.exp") + schema = subject.load_express(schema_path) subject.add_schema_identifier(schema) assert IfcStore.schema_identifiers[-1] == "IFCROGUE" + os.remove(schema_path + ".cache.dat") class TestLoadExpress(NewFile): def test_run(self): cwd = os.path.dirname(os.path.realpath(__file__)) - schema = subject.load_express(os.path.join(cwd, "..", "files", "test.exp")) + schema_path = os.path.join(cwd, "..", "files", "test.exp") + schema = subject.load_express(schema_path) assert schema.schema_name == "IFCROGUE" + os.remove(schema_path + ".cache.dat") class TestPurgeHdf5Cache(NewFile): diff --git a/src/blenderbim/test/tool/test_patch.py b/src/blenderbim/test/tool/test_patch.py index 4c1d2b63fa..6bbdcf737e 100644 --- a/src/blenderbim/test/tool/test_patch.py +++ b/src/blenderbim/test/tool/test_patch.py @@ -34,7 +34,7 @@ class TestRunMigratePatch(NewFile): def test_run(self): cwd = os.path.dirname(os.path.realpath(__file__)) infile = os.path.join(cwd, "..", "files", "ifc2x3.ifc") - outfile = os.path.join(cwd, "..", "files", "ifc2x3-migrated.ifc") + outfile = os.path.join(cwd, "..", "files", "temp", "ifc2x3-migrated.ifc") subject.run_migrate_patch(infile, outfile, "IFC4") ifc = ifcopenshell.open(outfile) assert ifc.schema == "IFC4"