Publish element classes MicroMVD definitions

This commit is contained in:
Dion Moult
2020-07-28 17:31:11 +10:00
parent 252479189c
commit 330aa1b6e3
2 changed files with 34 additions and 57 deletions
@@ -0,0 +1,34 @@
from behave import step
from utils import IfcFile, assert_attribute
@step('The element {guid} is an {ifc_class} only')
def step_impl(context, guid, ifc_class):
element = IfcFile.by_guid(guid)
assert element.is_a() == ifc_class, 'The element {} is an {} instead of {}.'.format(element, element.is_a(), ifc_class)
@step('The element {guid} is an {ifc_class}')
def step_impl(context, guid, ifc_class):
element = IfcFile.by_guid(guid)
assert element.is_a(ifc_class), 'The element {} is an {} instead of {}.'.format(element, element.is_a(), ifc_class)
@step('The element {guid} is further defined as a {predefined_type}')
def step_impl(context, guid, predefined_type):
element = IfcFile.by_guid(guid)
if (hasattr(element, 'PredefinedType') and element.PredefinedType == 'USERDEFINED') \
or hasattr(element,'ObjectType'):
assert_attribute(element, 'ObjectType', predefined_type)
elif hasattr(element, 'PredefinedType'):
assert_attribute(element, 'PredefinedType', predefined_type)
else:
assert False, 'The element {} does not have a PredefinedType or ObjectType attribute'.format(element)
@step('The element {guid} should not exist because {reason}')
def step_impl(context, guid, reason):
try:
element = IfcFile.get().by_id(guid)
except:
return
assert False, 'This element {} should be reevaluated.'.format(element)