From 15199152ac2fe3ad1aef44d3338c843888683f02 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 26 Nov 2020 07:37:29 +0100 Subject: [PATCH 1/3] bimtester: code formating and comments --- src/ifcbimtester/README.md | 13 +++++++++ src/ifcbimtester/bimtester.py | 45 +++++++++++++++++++++++-------- src/ifcbimtester/bimtester/run.py | 19 +++++++++++++ 3 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 src/ifcbimtester/README.md diff --git a/src/ifcbimtester/README.md b/src/ifcbimtester/README.md new file mode 100644 index 0000000000..079f7f54bf --- /dev/null +++ b/src/ifcbimtester/README.md @@ -0,0 +1,13 @@ +# BIMTester +### Packages to be installed ++ behave ++ pystache ++ ifcopenshell + + +### Create a binary out of the Python package ++ The commands needs to be updated ++ Unix: +`$ pyinstaller --onefile --clean --icon=icon.ico --add-data "features:features" bimtester.py` ++ Windows: + `$ pyinstaller --onefile --clean --icon=icon.ico --add-data "features;features" bimtester.py` diff --git a/src/ifcbimtester/bimtester.py b/src/ifcbimtester/bimtester.py index c33121b6fd..792886ef02 100644 --- a/src/ifcbimtester/bimtester.py +++ b/src/ifcbimtester/bimtester.py @@ -1,10 +1,5 @@ #!/usr/bin/env python3 -# Unix: -# $ pyinstaller --onefile --clean --icon=icon.ico --add-data "features:features" bimtester.py` -# Windows: -# $ pyinstaller --onefile --clean --icon=icon.ico --add-data "features;features" bimtester.py` - import argparse from bimtester import clean @@ -13,13 +8,41 @@ from bimtester import run if __name__ == "__main__": - 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") - 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="") + + parser = argparse.ArgumentParser( + description="Runs unit tests for BIM data" + ) parser.add_argument( - "-a", "--advanced-arguments", type=str, help="Specify your own arguments to Python's Behave", default="" + "-p", + "--purge", + action="store_true", + help="Purge tests of deleted elements" + ) + parser.add_argument( + "-r", + "--report", + action="store_true", + help="Generate a HTML report" + ) + 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="" + ) + parser.add_argument( + "-a", + "--advanced-arguments", + type=str, + help="Specify your own arguments to Python's Behave", + default="" ) args = vars(parser.parse_args()) diff --git a/src/ifcbimtester/bimtester/run.py b/src/ifcbimtester/bimtester/run.py index c64c54372f..4d4cbea046 100644 --- a/src/ifcbimtester/bimtester/run.py +++ b/src/ifcbimtester/bimtester/run.py @@ -107,6 +107,25 @@ run.run_all(myfeatures_path, myfeatures_path) # like German Umlaute behave gives an error +# TODO: change run_intmp_tests() and run_all() +# arguments feature_path and ifc_file +# +# both is given: +# replace the ifc in feature files +# +# feature_path only is given: +# use the ifc provided in the feature files +# +# ifc_file only is given: +# assume feature files are in the directory of the ifc +# +# none of both is given: +# use current directory and the ifc from feature files + + +# TODO: add arg for run_intmp_tests() to bimtester.py + + def run_intmp_tests(args={}): from behave import __version__ as behave_version From 5ce334019c1c4740c6b5fe9b8b6d8233511fb226 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 26 Nov 2020 07:38:50 +0100 Subject: [PATCH 2/3] bimtester: merge guibimtester into bimtester module --- src/ifcbimtester/README.md | 5 +++++ src/ifcbimtester/bimtester.py | 26 ++++++++++++++++++++++++++ src/ifcbimtester/guibimtester.py | 22 ---------------------- 3 files changed, 31 insertions(+), 22 deletions(-) delete mode 100644 src/ifcbimtester/guibimtester.py diff --git a/src/ifcbimtester/README.md b/src/ifcbimtester/README.md index 079f7f54bf..a02d4bf267 100644 --- a/src/ifcbimtester/README.md +++ b/src/ifcbimtester/README.md @@ -5,6 +5,11 @@ + ifcopenshell +### Start bimtester Gui from a shell +``` +python3 ./bimtester.py -g +``` + ### Create a binary out of the Python package + The commands needs to be updated + Unix: diff --git a/src/ifcbimtester/bimtester.py b/src/ifcbimtester/bimtester.py index 792886ef02..1847126024 100644 --- a/src/ifcbimtester/bimtester.py +++ b/src/ifcbimtester/bimtester.py @@ -7,6 +7,24 @@ from bimtester import reports from bimtester import run +def show_widget(): + + 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 + form = GuiWidgetBimTester() + form.show() + + # Run the main Qt loop + sys.exit(app.exec_()) + + if __name__ == "__main__": parser = argparse.ArgumentParser( @@ -44,12 +62,20 @@ if __name__ == "__main__": help="Specify your own arguments to Python's Behave", default="" ) + parser.add_argument( + "-g", + "--gui", + action="store_true", + help="Start with gui", + ) args = vars(parser.parse_args()) if args["purge"]: clean.TestPurger().purge() elif args["report"]: reports.generate_report() + elif args["gui"]: + show_widget() else: run.run_tests(args) print("# All tasks are complete :-)") diff --git a/src/ifcbimtester/guibimtester.py b/src/ifcbimtester/guibimtester.py deleted file mode 100644 index 000e4507a9..0000000000 --- a/src/ifcbimtester/guibimtester.py +++ /dev/null @@ -1,22 +0,0 @@ -# TODO merge into bimtester module - -import sys -from PySide2 import QtWidgets - -from bimtester.guiwidget import GuiWidgetBimTester - - -def show_widget(): - - # Create the Qt Application - app = QtWidgets.QApplication(sys.argv) - - # Create and show the form - form = GuiWidgetBimTester() - form.show() - - # Run the main Qt loop - sys.exit(app.exec_()) - -if __name__ == '__main__': - show_widget() From b88eb37bdf6c78ee6f57fbe02ad94585983dc1bb Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 26 Nov 2020 08:08:38 +0100 Subject: [PATCH 3/3] bimtester: improve imports in steps --- src/ifcbimtester/bimtester/features/steps/classification.py | 5 ++++- src/ifcbimtester/bimtester/features/steps/element_classes.py | 5 ++++- src/ifcbimtester/bimtester/features/steps/project_setup.py | 3 ++- src/ifcbimtester/bimtester/features/steps/steps.py | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ifcbimtester/bimtester/features/steps/classification.py b/src/ifcbimtester/bimtester/features/steps/classification.py index 40f2201252..3ed1e8d35a 100644 --- a/src/ifcbimtester/bimtester/features/steps/classification.py +++ b/src/ifcbimtester/bimtester/features/steps/classification.py @@ -1,6 +1,9 @@ import json from behave import step -from utils import IfcFile, assert_attribute, assert_type + +from utils import assert_attribute +from utils import assert_type +from utils import IfcFile def get_classification(name): diff --git a/src/ifcbimtester/bimtester/features/steps/element_classes.py b/src/ifcbimtester/bimtester/features/steps/element_classes.py index a3908ce2b6..07ea37ffce 100644 --- a/src/ifcbimtester/bimtester/features/steps/element_classes.py +++ b/src/ifcbimtester/bimtester/features/steps/element_classes.py @@ -1,5 +1,8 @@ from behave import step -from utils import IfcFile, assert_attribute, assert_type + +from utils import assert_attribute +from utils import assert_type +from utils import IfcFile @step("The element {guid} is an {ifc_class} only") diff --git a/src/ifcbimtester/bimtester/features/steps/project_setup.py b/src/ifcbimtester/bimtester/features/steps/project_setup.py index c8abb39ca2..14fc480fa3 100644 --- a/src/ifcbimtester/bimtester/features/steps/project_setup.py +++ b/src/ifcbimtester/bimtester/features/steps/project_setup.py @@ -1,6 +1,7 @@ from behave import step + +from utils import assert_attribute from utils import IfcFile -from utils import IfcFile, assert_attribute @step('The IFC file "{file}" must be provided') diff --git a/src/ifcbimtester/bimtester/features/steps/steps.py b/src/ifcbimtester/bimtester/features/steps/steps.py index 4d48bde68e..8627efd419 100644 --- a/src/ifcbimtester/bimtester/features/steps/steps.py +++ b/src/ifcbimtester/bimtester/features/steps/steps.py @@ -1,4 +1,5 @@ from behave import step + from utils import IfcFile