diff --git a/src/ifcbimtester/bimtester/features/steps/attributes_eleclasses.py b/src/ifcbimtester/bimtester/features/steps/attributes_eleclasses.py index 43cee4e9e5..c39467568f 100644 --- a/src/ifcbimtester/bimtester/features/steps/attributes_eleclasses.py +++ b/src/ifcbimtester/bimtester/features/steps/attributes_eleclasses.py @@ -1,11 +1,13 @@ from behave import step +from attributes_eleclasses_methods import no_element_class_ele from utils import IfcFile @step("there are no {ifc_class} elements because {reason}") def step_impl(context, ifc_class, reason): - assert len(IfcFile.get().by_type(ifc_class)) == 0 + switch_locale(context.localedir, "en") + no_element_class_ele(context, ifc_class, reason) @step('all {ifc_class} elements have a name matching the pattern "{pattern}"') diff --git a/src/ifcbimtester/bimtester/features/steps/attributes_eleclasses_methods.py b/src/ifcbimtester/bimtester/features/steps/attributes_eleclasses_methods.py new file mode 100644 index 0000000000..ddd1238d9f --- /dev/null +++ b/src/ifcbimtester/bimtester/features/steps/attributes_eleclasses_methods.py @@ -0,0 +1,41 @@ +import gettext # noqa +from utils import assert_elements +from utils import IfcFile + + +def no_element_class_ele(context, ifc_class, reason): + + context.falseelems = [] + context.falseguids = [] + + elements = IfcFile.get().by_type(ifc_class) + for elem in elements: + context.falseelems.append(str(elem)) + context.falseguids.append(elem.GlobalId) + + context.elemcount = len(elements) + context.falsecount = len(context.falseelems) + + + if context.elemcount == 0 and context.falsecount == 0: + return # Test OK, thus we can not use the assert_elements method + elif context.falsecount == context.elemcount: + assert False, ( + _("All {elemcount} elements in the file are {ifc_class}.") + .format( + elemcount=context.elemcount, + ifc_class=ifc_class + ) + ) + elif context.falsecount > 0 and fcontext.alsecount < context.elemcount: + assert False, ( + _("{falsecount} of {elemcount} element are {ifc_class} elements: {falseelems}") + .format( + falsecount=context.falsecount, + elemcount=context.elemcount, + ifc_class=ifc_class, + falseelems=context.falseelems, + ) + ) + else: + assert False, _("Error in falsecount, something went wrong.")