bimtester: step, prepare attributes eleclasses for translation

This commit is contained in:
Bernd Hahnebach
2020-12-21 16:57:38 +01:00
parent dafdd06b2e
commit 2a6efaaaa4
2 changed files with 44 additions and 1 deletions
@@ -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}"')
@@ -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.")