mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
bimtester, attributes ele class steps, use generic assert methond
This commit is contained in:
@@ -95,36 +95,18 @@ def only_eleclasses(
|
|||||||
if elem.is_a() not in target_ifc_classes:
|
if elem.is_a() not in target_ifc_classes:
|
||||||
context.falseelems.append(str(elem))
|
context.falseelems.append(str(elem))
|
||||||
context.falseguids.append(elem.GlobalId)
|
context.falseguids.append(elem.GlobalId)
|
||||||
|
|
||||||
out_falseelems = "\n"
|
|
||||||
for e in context.falseelems:
|
|
||||||
out_falseelems += e + "\n"
|
|
||||||
context.falsecount = len(context.falseelems)
|
context.falsecount = len(context.falseelems)
|
||||||
# print(context.falsecount)
|
|
||||||
# print(context.elemcount)
|
|
||||||
|
|
||||||
if context.falsecount == 0:
|
# use ifc_classes in method parameter but ifc_class in string parameter
|
||||||
return # Test OK, thus we can not use the assert_elements method ... really ?
|
# be careful somehow the opposite of most other tests is tested
|
||||||
elif context.falsecount == context.elemcount:
|
util.assert_elements(
|
||||||
assert False, (
|
ifc_classes,
|
||||||
_("All {elemcount} false elements in the file are {ifc_classes}.")
|
context.elemcount,
|
||||||
.format(
|
context.falsecount,
|
||||||
elemcount=context.elemcount,
|
context.falseelems,
|
||||||
ifc_classes=ifc_classes
|
message_all_falseelems=_("All {elemcount} elements in the file are not {ifc_class} elements."),
|
||||||
)
|
message_some_falseelems=_("{falsecount} of {elemcount} false_elements are not {ifc_class} elements: {falseelems}"),
|
||||||
)
|
)
|
||||||
elif context.falsecount > 0 and context.falsecount < context.elemcount:
|
|
||||||
assert False, (
|
|
||||||
_("{falsecount} of {elemcount} false_elements are {ifc_classes} false_elements: {falseelems}")
|
|
||||||
.format(
|
|
||||||
falsecount=context.falsecount,
|
|
||||||
elemcount=context.elemcount,
|
|
||||||
ifc_classes=ifc_classes,
|
|
||||||
falseelems=out_falseelems,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
assert False, _("Error in falsecount, something went wrong.")
|
|
||||||
|
|
||||||
|
|
||||||
def no_eleclass(
|
def no_eleclass(
|
||||||
@@ -139,36 +121,17 @@ def no_eleclass(
|
|||||||
for elem in elements:
|
for elem in elements:
|
||||||
context.falseelems.append(str(elem))
|
context.falseelems.append(str(elem))
|
||||||
context.falseguids.append(elem.GlobalId)
|
context.falseguids.append(elem.GlobalId)
|
||||||
|
|
||||||
out_falseelems = "\n"
|
|
||||||
for e in context.falseelems:
|
|
||||||
out_falseelems += e + "\n"
|
|
||||||
context.falsecount = len(context.falseelems)
|
context.falsecount = len(context.falseelems)
|
||||||
# print(context.falsecount)
|
|
||||||
# print(context.elemcount)
|
|
||||||
|
|
||||||
if context.falsecount == 0:
|
# be careful somehow the opposite of most other tests is tested
|
||||||
return # Test OK, thus we can not use the assert_elements method ... really ?
|
util.assert_elements(
|
||||||
elif context.falsecount == context.elemcount:
|
ifc_class,
|
||||||
assert False, (
|
context.elemcount,
|
||||||
_("All {elemcount} elements in the file are {ifc_class}.")
|
context.falsecount,
|
||||||
.format(
|
context.falseelems,
|
||||||
elemcount=context.elemcount,
|
message_all_falseelems=_("All {elemcount} elements in the file are {ifc_class} elements."),
|
||||||
ifc_class=ifc_class
|
message_some_falseelems=_("{falsecount} of {elemcount} false_elements are {ifc_class} elements: {falseelems}"),
|
||||||
)
|
)
|
||||||
)
|
|
||||||
elif context.falsecount > 0 and context.falsecount < context.elemcount:
|
|
||||||
assert False, (
|
|
||||||
_("{falsecount} of {elemcount} elements are {ifc_class} elements: {falseelems}")
|
|
||||||
.format(
|
|
||||||
falsecount=context.falsecount,
|
|
||||||
elemcount=context.elemcount,
|
|
||||||
ifc_class=ifc_class,
|
|
||||||
falseelems=out_falseelems,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
assert False, _("Error in falsecount, something went wrong.")
|
|
||||||
|
|
||||||
|
|
||||||
def eleclass_have_class_attributes_with_a_value(
|
def eleclass_have_class_attributes_with_a_value(
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ def assert_elements(
|
|||||||
falseelems,
|
falseelems,
|
||||||
message_all_falseelems,
|
message_all_falseelems,
|
||||||
message_some_falseelems,
|
message_some_falseelems,
|
||||||
message_no_elems,
|
message_no_elems="",
|
||||||
parameter=None
|
parameter=None
|
||||||
):
|
):
|
||||||
out_falseelems = "\n"
|
out_falseelems = "\n"
|
||||||
@@ -112,7 +112,7 @@ def assert_elements(
|
|||||||
# )
|
# )
|
||||||
# )
|
# )
|
||||||
if falsecount == 0:
|
if falsecount == 0:
|
||||||
return # test ok for elemcount == 0 !!!
|
return # test ok for elemcount == 0 and elemcount > 0
|
||||||
elif falsecount == elemcount:
|
elif falsecount == elemcount:
|
||||||
if parameter is None:
|
if parameter is None:
|
||||||
assert False, (
|
assert False, (
|
||||||
@@ -150,4 +150,4 @@ def assert_elements(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
assert False, _("Error in falsecount, something went wrong.")
|
assert False, _("Error in falsecount calculation, something went wrong.")
|
||||||
|
|||||||
Reference in New Issue
Block a user