2020-07-31 16:12:14 +10:00
|
|
|
#!/usr/bin/env python3
|
2020-11-23 09:34:13 +01:00
|
|
|
|
|
|
|
|
import argparse
|
2019-11-15 15:43:33 +11:00
|
|
|
|
2020-11-25 17:21:20 +01:00
|
|
|
from bimtester import clean
|
|
|
|
|
from bimtester import reports
|
|
|
|
|
from bimtester import run
|
2019-11-15 15:43:33 +11:00
|
|
|
|
2020-04-02 18:38:42 +11:00
|
|
|
|
2020-11-27 17:55:06 +01:00
|
|
|
def show_widget(features="", ifcfile=""):
|
2020-11-26 07:38:50 +01:00
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
from PySide2 import QtWidgets
|
|
|
|
|
|
|
|
|
|
from bimtester.guiwidget import GuiWidgetBimTester
|
|
|
|
|
|
|
|
|
|
# Create the Qt Application
|
|
|
|
|
app = QtWidgets.QApplication(sys.argv)
|
|
|
|
|
|
|
|
|
|
# Create and show the form
|
2020-11-27 17:55:06 +01:00
|
|
|
form = GuiWidgetBimTester(features, ifcfile)
|
2020-11-26 07:38:50 +01:00
|
|
|
form.show()
|
|
|
|
|
|
|
|
|
|
# Run the main Qt loop
|
|
|
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
|
|
|
|
|
2020-07-23 13:42:41 +10:00
|
|
|
if __name__ == "__main__":
|
2020-11-26 07:37:29 +01:00
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
description="Runs unit tests for BIM data"
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"-p",
|
|
|
|
|
"--purge",
|
|
|
|
|
action="store_true",
|
|
|
|
|
help="Purge tests of deleted elements"
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"-r",
|
|
|
|
|
"--report",
|
|
|
|
|
action="store_true",
|
|
|
|
|
help="Generate a HTML report"
|
|
|
|
|
)
|
2020-12-10 10:35:13 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
"-rr",
|
|
|
|
|
"--report_after_run",
|
|
|
|
|
action="store_true",
|
|
|
|
|
help="Generate a HTML report after running the tests"
|
|
|
|
|
)
|
2020-12-18 11:22:51 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
"-path",
|
|
|
|
|
"--path",
|
|
|
|
|
type=str,
|
|
|
|
|
help=(
|
|
|
|
|
"Specify a path to prepend to feature and ifc file"
|
|
|
|
|
),
|
|
|
|
|
default=""
|
|
|
|
|
)
|
2020-11-26 07:37:29 +01:00
|
|
|
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",
|
|
|
|
|
default=""
|
|
|
|
|
)
|
2020-07-23 13:42:41 +10:00
|
|
|
parser.add_argument(
|
2020-11-26 07:37:29 +01:00
|
|
|
"-a",
|
|
|
|
|
"--advanced-arguments",
|
|
|
|
|
type=str,
|
|
|
|
|
help="Specify your own arguments to Python's Behave",
|
|
|
|
|
default=""
|
2020-07-23 13:42:41 +10:00
|
|
|
)
|
2020-11-26 07:38:50 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
"-g",
|
|
|
|
|
"--gui",
|
|
|
|
|
action="store_true",
|
2020-11-27 17:55:06 +01:00
|
|
|
help=(
|
|
|
|
|
"Start the gui. The option t (run in temp directory) "
|
|
|
|
|
"is triggered automaticly."
|
|
|
|
|
)
|
2020-11-26 07:38:50 +01:00
|
|
|
)
|
2020-11-27 17:55:06 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
"featuresdir",
|
|
|
|
|
type=str,
|
|
|
|
|
nargs="?",
|
|
|
|
|
help=(
|
|
|
|
|
"Specify a features directory. This should contain "
|
|
|
|
|
" a directory named features which contains all the "
|
|
|
|
|
"feature files."
|
|
|
|
|
),
|
|
|
|
|
default=""
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"ifcfile",
|
|
|
|
|
type=str,
|
|
|
|
|
nargs="?",
|
|
|
|
|
help=(
|
|
|
|
|
"Specify a ifc file."
|
|
|
|
|
),
|
|
|
|
|
default=""
|
|
|
|
|
)
|
|
|
|
|
|
2020-07-23 13:42:41 +10:00
|
|
|
args = vars(parser.parse_args())
|
2020-11-27 17:55:06 +01:00
|
|
|
print(args)
|
2020-07-23 13:42:41 +10:00
|
|
|
|
2020-12-18 11:22:51 +01:00
|
|
|
if args["path"]:
|
|
|
|
|
if args["feature"]:
|
|
|
|
|
args["feature"] = os.path.join(args["path"], args["feature"])
|
|
|
|
|
if not args["gui"]:
|
|
|
|
|
args["ifcfile"] = os.path.join(args["path"], args["ifcfile"])
|
|
|
|
|
|
2020-07-23 13:42:41 +10:00
|
|
|
if args["purge"]:
|
2020-11-23 09:34:13 +01:00
|
|
|
clean.TestPurger().purge()
|
2020-07-23 13:42:41 +10:00
|
|
|
elif args["report"]:
|
2020-11-23 09:34:13 +01:00
|
|
|
reports.generate_report()
|
2020-11-26 07:38:50 +01:00
|
|
|
elif args["gui"]:
|
2020-11-27 17:55:06 +01:00
|
|
|
show_widget(args["featuresdir"], args["ifcfile"])
|
2020-07-23 13:42:41 +10:00
|
|
|
else:
|
2020-11-23 09:34:13 +01:00
|
|
|
run.run_tests(args)
|
2020-12-10 10:35:13 +01:00
|
|
|
if args["report_after_run"]:
|
|
|
|
|
reports.generate_report()
|
2020-07-23 13:42:41 +10:00
|
|
|
print("# All tasks are complete :-)")
|