mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
You can now specify a set of custom step definitions to BIMTester.
This commit is contained in:
@@ -3,8 +3,13 @@ import sys
|
||||
import shutil
|
||||
import tempfile
|
||||
import ifcopenshell
|
||||
try:
|
||||
import ifcopenshell.express
|
||||
except:
|
||||
pass # They are using an old version of IfcOpenShell. Gracefully degrade for now.
|
||||
import behave.formatter.pretty # Needed for pyinstaller to package it
|
||||
from bimtester.ifc import IfcStore
|
||||
from distutils.dir_util import copy_tree
|
||||
from behave.__main__ import main as behave_main
|
||||
|
||||
|
||||
@@ -14,7 +19,6 @@ class TestRunner:
|
||||
IfcStore.file = ifc if ifc else ifcopenshell.open(ifc_path)
|
||||
|
||||
if schema:
|
||||
import ifcopenshell.express
|
||||
schema = ifcopenshell.express.parse(path)
|
||||
ifcopenshell.register_schema(schema)
|
||||
|
||||
@@ -29,9 +33,15 @@ class TestRunner:
|
||||
def run(self, args):
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
features_path = os.path.join(tmpdir, "features")
|
||||
steps_path = os.path.join(features_path, "steps")
|
||||
report_json = os.path.join(tmpdir, "report.json")
|
||||
shutil.copytree(os.path.join(self.base_path, "features"), features_path)
|
||||
shutil.copy(args["feature"], features_path)
|
||||
if args["steps"]:
|
||||
if os.path.isfile(args["steps"]):
|
||||
shutil.copy(args["steps"], steps_path)
|
||||
elif os.path.isdir(args["steps"]):
|
||||
copy_tree(args["steps"], steps_path)
|
||||
behave_main(self.get_behave_args(args, features_path, report_json))
|
||||
return report_json
|
||||
|
||||
|
||||
Executable → Regular
+1
@@ -14,6 +14,7 @@ parser.add_argument("-f", "--feature", type=str, help="Specify a feature file to
|
||||
parser.add_argument("-i", "--ifc", type=str, help="Specify a ifc file", required=True)
|
||||
parser.add_argument("-p", "--path", type=str, help="Define a path for use in tests")
|
||||
parser.add_argument("-r", "--report", type=str, help="Specify an output file for a HTML report")
|
||||
parser.add_argument("--steps", type=str, help="Specify custom step definitions")
|
||||
parser.add_argument("--schema", type=str, help="Specify an output file for a HTML report")
|
||||
parser.add_argument("--lang", type=str, help="Specify a language", default="")
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ classes = (
|
||||
operator.ExecuteBIMTester,
|
||||
operator.BIMTesterPurge,
|
||||
operator.SelectFeature,
|
||||
operator.SelectSteps,
|
||||
operator.SelectBIMTesterIfcFile,
|
||||
operator.RejectElement,
|
||||
operator.ApproveClass,
|
||||
|
||||
@@ -29,7 +29,8 @@ class ExecuteBIMTester(bpy.types.Operator):
|
||||
"path": "",
|
||||
"report": report,
|
||||
"schema": "",
|
||||
"lang": "en"
|
||||
"lang": "en",
|
||||
"steps": props.steps
|
||||
}
|
||||
use_stored_ifc = props.should_load_from_memory and IfcStore.get_file()
|
||||
runner = bimtester.run.TestRunner(args["ifc"], ifc=IfcStore.get_file() if use_stored_ifc else None)
|
||||
@@ -71,6 +72,22 @@ class SelectFeature(bpy.types.Operator):
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
|
||||
class SelectSteps(bpy.types.Operator):
|
||||
bl_idname = "bim.select_steps"
|
||||
bl_label = "Select Steps"
|
||||
filename_ext = ".py"
|
||||
filter_glob: bpy.props.StringProperty(default="*.py", options={"HIDDEN"})
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.BimTesterProperties.steps = self.filepath
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
|
||||
class SelectBIMTesterIfcFile(bpy.types.Operator):
|
||||
bl_idname = "bim.select_bimtester_ifc_file"
|
||||
bl_label = "Select BIMTester IFC File"
|
||||
|
||||
@@ -42,6 +42,7 @@ def refreshScenarios(self, context):
|
||||
|
||||
class BimTesterProperties(PropertyGroup):
|
||||
feature: StringProperty(default="", name="Feature File", update=refreshScenarios)
|
||||
steps: StringProperty(default="", name="Custom Steps")
|
||||
ifc_file: StringProperty(default="", name="IFC File")
|
||||
audit_ifc_class: EnumProperty(items=getIfcClasses, name="Audit Class")
|
||||
qa_reject_element_reason: StringProperty(name="Element Rejection Reason")
|
||||
|
||||
@@ -28,6 +28,10 @@ class BIM_PT_qa(Panel):
|
||||
row.prop(props, "feature")
|
||||
row.operator("bim.select_feature", icon="FILE_FOLDER", text="")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(props, "steps")
|
||||
row.operator("bim.select_steps", icon="FILE_FOLDER", text="")
|
||||
|
||||
has_ifc_file = (IfcStore.get_file() and props.should_load_from_memory) or (
|
||||
props.ifc_file and not props.should_load_from_memory
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user