diff --git a/src/ifcbimtester/bimtester/features/steps/ifcdata.py b/src/ifcbimtester/bimtester/features/steps/ifcdata.py index 11c4a02053..5a3b3e6027 100644 --- a/src/ifcbimtester/bimtester/features/steps/ifcdata.py +++ b/src/ifcbimtester/bimtester/features/steps/ifcdata.py @@ -1,5 +1,6 @@ from behave import step +from utils import assert_schema from utils import IfcFile @@ -13,10 +14,9 @@ def step_impl(context, file): @step("IFC data must use the {schema} schema") def step_impl(context, schema): - assert IfcFile.get().schema == schema, "We expected a schema of {} but instead got {}".format( - schema, IfcFile.get().schema - ) - + context.schema = IfcFile.get().schema + assert_schema(schema, context.schema) + @step('The IFC file "{file}" is exempt from being provided') def step_impl(context, file): diff --git a/src/ifcbimtester/bimtester/features/steps/ifcdata_de.py b/src/ifcbimtester/bimtester/features/steps/ifcdata_de.py index 69e284a73f..a21d248782 100644 --- a/src/ifcbimtester/bimtester/features/steps/ifcdata_de.py +++ b/src/ifcbimtester/bimtester/features/steps/ifcdata_de.py @@ -1,10 +1,19 @@ from behave import step +from utils import assert_schema + + # https://behave.readthedocs.io/en/latest/api.html#step-macro-calling-steps-from-other-steps +# https://stackoverflow.com/questions/46735425/how-to-only-show-failing-tests-from-behave +# https://community.osarch.org/discussion/comment/4533/#Comment_4533 - -@step("Die IFC daten müssen das {schema} Schema benutzen") +@step("Die IFC Daten müssen das {schema} Schema benutzen") def step_impl(context, schema): - context.execute_steps( - "* IFC data must use the {schema} schema".format(schema=schema) - ) + try: + context.execute_steps( + "* IFC data must use the {schema} schema".format(schema=schema) + ) + except Exception: + assert_schema(schema, context.schema) + # TODO translate error + # "Wir haben ein Schema {} erwartet, aber die Daten sind Schema (}" diff --git a/src/ifcbimtester/bimtester/features/steps/ifcdata_fr.py b/src/ifcbimtester/bimtester/features/steps/ifcdata_fr.py index c7947f9719..ed465fe02a 100644 --- a/src/ifcbimtester/bimtester/features/steps/ifcdata_fr.py +++ b/src/ifcbimtester/bimtester/features/steps/ifcdata_fr.py @@ -1,10 +1,13 @@ from behave import step -# https://behave.readthedocs.io/en/latest/api.html#step-macro-calling-steps-from-other-steps +from utils import assert_schema @step("Les données IFC doivent utiliser le schéma {schema}") def step_impl(context, schema): - context.execute_steps( - "* IFC data must use the {aschema} schema".format(aschema=schema) - ) + try: + context.execute_steps( + "* IFC data must use the {schema} schema".format(schema=schema) + ) + except Exception: + assert_schema(schema, context.schema) diff --git a/src/ifcbimtester/bimtester/features/steps/utils.py b/src/ifcbimtester/bimtester/features/steps/utils.py index 038b0c4149..5ae6c8c180 100644 --- a/src/ifcbimtester/bimtester/features/steps/utils.py +++ b/src/ifcbimtester/bimtester/features/steps/utils.py @@ -78,3 +78,10 @@ def assert_pset(element, pset_name, prop_name=None, value=None): assert actual_value == value, 'We expected a value of "{}" but instead got "{}" for the element {}'.format( value, actual_value, element ) + + +def assert_schema(real_schema, target_schema): + assert real_schema == target_schema, ( + "We expected a schema of {} but instead got {}" + .format(target_schema, real_schema) + )