2020-07-28 17:31:11 +10:00
|
|
|
from behave import step
|
2020-08-06 18:32:33 +10:00
|
|
|
from utils import IfcFile, assert_attribute, assert_type
|
2020-07-28 17:31:11 +10:00
|
|
|
|
|
|
|
|
@step('The element {guid} is an {ifc_class} only')
|
|
|
|
|
def step_impl(context, guid, ifc_class):
|
|
|
|
|
element = IfcFile.by_guid(guid)
|
2020-08-06 18:32:33 +10:00
|
|
|
assert_type(element, ifc_class, is_exact=True)
|
2020-07-28 17:31:11 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@step('The element {guid} is an {ifc_class}')
|
|
|
|
|
def step_impl(context, guid, ifc_class):
|
|
|
|
|
element = IfcFile.by_guid(guid)
|
2020-08-06 18:32:33 +10:00
|
|
|
assert_type(element, ifc_class)
|
2020-07-28 17:31:11 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@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)
|