diff --git a/src/ifcbimtester/bimtester/reports.py b/src/ifcbimtester/bimtester/reports.py
index 2e4e2098c9..5a6683df0d 100644
--- a/src/ifcbimtester/bimtester/reports.py
+++ b/src/ifcbimtester/bimtester/reports.py
@@ -21,12 +21,12 @@ class ReportGenerator:
self.generate_feature_report(feature, output_file)
def generate_feature_report(self, feature, output_file):
- file_name = os.path.basename(feature["location"]).split(":")[0]
+ # file_name = os.path.basename(feature["location"]).split(":")[0]
data = {
- "file_name": file_name,
+ # "file_name": file_name,
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"name": feature["name"],
- "description": feature["description"],
+ "description": feature.get("description", ""),
"is_success": feature["status"] == "passed",
"scenarios": [],
}
diff --git a/src/ifcbimtester/bimtester/resources/reports/template.html b/src/ifcbimtester/bimtester/resources/reports/template.html
index 98761cc5e1..94a0a31f34 100644
--- a/src/ifcbimtester/bimtester/resources/reports/template.html
+++ b/src/ifcbimtester/bimtester/resources/reports/template.html
@@ -35,11 +35,11 @@
{{#is_success}}{{_success}}{{/is_success}}{{^is_success}}{{_failure}}{{/is_success}}
{{_tests_passed}}: {{total_passes}} / {{total_steps}} ({{pass_rate}}%)
+ {{#description}}
- {{#description}}
{{.}}
- {{/description}}
+ {{/description}}
{{#scenarios}}
diff --git a/src/ifcbimtester/bimtester/run.py b/src/ifcbimtester/bimtester/run.py
index a95dd6af42..a80867ffeb 100644
--- a/src/ifcbimtester/bimtester/run.py
+++ b/src/ifcbimtester/bimtester/run.py
@@ -1,6 +1,8 @@
import os
import sys
+import json
import shutil
+import logging
import tempfile
import ifcopenshell
@@ -14,6 +16,46 @@ from distutils.dir_util import copy_tree
from behave.__main__ import main as behave_main
+# TODO: refactor when this isn't super experimental
+from logging import StreamHandler
+
+class IDSHandler(StreamHandler):
+ def __init__(self):
+ StreamHandler.__init__(self)
+ self.results = {
+ "name": "Specification name",
+ "status": "passed",
+ "location": "filename.xml",
+ "elements": [
+ {
+ "keyword": "Scenario",
+ "name": "Checking IDS specifications",
+ "status": "passed",
+ "steps": []
+ }
+ ]
+ }
+
+ def emit(self, record):
+ msg = self.format(record)
+ # Obviously, not a final product
+ is_fail = "is compliant" not in msg
+ if is_fail:
+ self.results["status"] = "failed"
+ self.results["elements"][0]["status"] = "failed"
+ self.results["elements"][0]["steps"].append({
+ "keyword": "*",
+ "match": {},
+ "name": msg,
+ "result": {
+ "duration": 0.0,
+ "error_message": "Assertion Failed",
+ "status": "failed" if is_fail else "passed"
+ },
+ "step_type": "given"
+ })
+
+
class TestRunner:
def __init__(self, ifc_path, schema_path=None, ifc=None):
IfcStore.path = ifc_path
@@ -34,6 +76,27 @@ class TestRunner:
self.locale_path = os.path.join(self.base_path, "locale")
def run(self, args):
+ if args["feature"][-4:].lower() == ".xml":
+ return self.test_ids(args)
+ return self.test_feature(args)
+
+ def test_ids(self, args):
+ # Local import whilst this is experimental
+ import ifcopenshell.ids
+
+ logger = logging.getLogger("IDS")
+ logging.basicConfig(level=logging.INFO, format="%(message)s")
+ ids_handler = IDSHandler()
+ logger.addHandler(ids_handler)
+ ids_file = ifcopenshell.ids.ids(args["feature"])
+ ids_file.validate(IfcStore.file, logger)
+
+ tmpdir = tempfile.mkdtemp()
+ report_json = os.path.join(tmpdir, "report.json")
+ json.dump([ids_handler.results], open(report_json, "w"))
+ return report_json
+
+ def test_feature(self, args):
tmpdir = tempfile.mkdtemp()
features_path = os.path.join(tmpdir, "features")
steps_path = os.path.join(features_path, "steps")
diff --git a/src/ifcbimtester/cli.py b/src/ifcbimtester/cli.py
index 38179de6b6..b7609d2398 100644
--- a/src/ifcbimtester/cli.py
+++ b/src/ifcbimtester/cli.py
@@ -10,7 +10,7 @@ parser = argparse.ArgumentParser(description="Runs unit tests for BIM data")
parser.add_argument("-a", "--action", type=str, help="Action to perform, from run/purge", default="run")
parser.add_argument("--advanced-arguments", type=str, help="Specify arguments to Behave", default="")
parser.add_argument("-c", "--console", action="store_true", help="Show results in the console")
-parser.add_argument("-f", "--feature", type=str, help="Specify a feature file to test", required=True)
+parser.add_argument("-f", "--feature", type=str, help="Specify a feature file or IDS to test", required=True)
parser.add_argument("-i", "--ifc", type=str, help="Specify an IFC file to test", required=True)
parser.add_argument("-p", "--path", type=str, help="Define a path for use in test steps that use relative paths")
parser.add_argument("-r", "--report", type=str, help="Specify an output file for a HTML report")