mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 15:53:00 +00:00
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
|
|
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)
|