From 330aa1b6e39d5b0bd7784c052579bd4e1bc1e080 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 28 Jul 2020 17:31:11 +1000 Subject: [PATCH] Publish element classes MicroMVD definitions --- .../features/steps/element_classes.py | 34 +++++++++++ src/ifcbimtester/features/steps/steps.py | 57 ------------------- 2 files changed, 34 insertions(+), 57 deletions(-) create mode 100644 src/ifcbimtester/features/steps/element_classes.py diff --git a/src/ifcbimtester/features/steps/element_classes.py b/src/ifcbimtester/features/steps/element_classes.py new file mode 100644 index 0000000000..d0330d85e4 --- /dev/null +++ b/src/ifcbimtester/features/steps/element_classes.py @@ -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) diff --git a/src/ifcbimtester/features/steps/steps.py b/src/ifcbimtester/features/steps/steps.py index 6a4d59edf2..64a7ed522b 100644 --- a/src/ifcbimtester/features/steps/steps.py +++ b/src/ifcbimtester/features/steps/steps.py @@ -1,50 +1,6 @@ from behave import step from utils import IfcFile -# Custom MicroMVD - -@step('The element {id} is an {ifc_class} only') -def step_impl(context, id, ifc_class): - try: - element = IfcFile.get().by_id(id) - except: - assert False, f'The element with {id} could not be found.' - assert element.is_a() == ifc_class, 'The element {} is an {} instead of {}.'.format(element, element.is_a(), ifc_class) - - -@step('The element {id} is an {ifc_class}') -def step_impl(context, id, ifc_class): - try: - element = IfcFile.get().by_id(id) - except: - assert False, f'The element with {id} could not be found.' - assert element.is_a(ifc_class), 'The element {} is an {} instead of {}.'.format(element, element.is_a(), ifc_class) - - -@step('The element {id} is further defined as a {predefined_type}') -def step_impl(context, id, predefined_type): - try: - element = IfcFile.get().by_id(id) - except: - assert False, f'The element with {id} could not be found.' - if element.PredefinedType == predefined_type: - return - if element.PredefinedType == 'USERDEFINED' and element.ObjectType == 'predefined_type': - return - assert False, 'The element {} has a predefined type of {} and an object type of {} instead of {}.'.format(element, element.PredefinedType, element.ObjectType, predefined_type) - - -@step('The element {id} should not exist because {reason}') -def step_impl(context, id, reason): - try: - element = IfcFile.get().by_id(id) - except: - return - assert False, 'This element {} should be reevaluated.'.format(element) - - - - @step(u'there are no {ifc_class} elements because {reason}') def step_impl(context, ifc_class, reason): assert len(IfcFile.get().by_type(ifc_class)) == 0 @@ -167,19 +123,6 @@ def step_impl(context, ifc_class, qto_name, quantity_name): assert False - - -use_step_matcher('re') -@step(u'the geolocated datum has an? (?P.*) of "(?P.*)"') -def step_impl(context, attribute, value): - if IfcFile.get().schema == 'IFC2X3': - site = IfcFile.get().by_type('IfcSite')[0] - actual_value = IfcFile.get_property(site, 'EPset_MapConversion', attribute).NominalValue.wrappedValue - else: - actual_value = getattr(IfcFile.get().by_id(IfcFile.bookmarks['geolocation']), attribute) - assert str(actual_value) == value, f'The value was {actual_value}' - - use_step_matcher('parse') @step(u'the project has a {attribute_name} attribute with a value of "{attribute_value}"') def step_impl(context, attribute_name, attribute_value):