removed get_property in attributes_psets step file (not implemented yet) (#1596)

* removed get_property in attributes_psets step file (not implemented yet)

problem with stepmatcher remains

* Fix pattern search for properties
This commit is contained in:
dedicos
2021-07-28 09:51:16 +02:00
committed by GitHub
parent 52f15d27b1
commit 5cab72deaa
2 changed files with 27 additions and 15 deletions
@@ -5,7 +5,7 @@ from bimtester.util import assert_elements
from bimtester.lang import _ from bimtester.lang import _
@step("all {ifc_class} elements have an {aproperty} property in the {pset} pset") @step("All {ifc_class} elements have an {aproperty} property in the {pset} pset")
def step_impl(context, ifc_class, aproperty, pset): def step_impl(context, ifc_class, aproperty, pset):
eleclass_has_property_in_pset( eleclass_has_property_in_pset(
context, context,
@@ -21,31 +21,42 @@ def step_impl(context, ifc_class, aproperty, pset):
use_step_matcher("re") use_step_matcher("re")
@step(r"all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property") @step(r"All (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property")
def step_impl(context, ifc_class, property_path): def step_impl(context, ifc_class, property_path):
pset_name, property_name = property_path.split(".") import re
elements = IfcStore.file.by_type(ifc_class) pset, aproperty = property_path.split(".")
for element in elements: eleclass_has_property_in_pset(
if not IfcStore.file.get_property(element, pset_name, property_name): context,
assert False ifc_class,
aproperty,
pset
)
@step( @step(r'All (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property value matching the pattern "(?P<pattern>.*)"'
r'all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property value matching the pattern "(?P<pattern>.*)"'
) )
def step_impl(context, ifc_class, property_path, pattern): def step_impl(context, ifc_class, property_path, pattern):
import re import re
from ifcopenshell.util.element import get_psets
pset_name, property_name = property_path.split(".") pset_name, property_name = property_path.split(".")
elements = IfcStore.file.by_type(ifc_class) elements = IfcStore.file.by_type(ifc_class)
for element in elements: for element in elements:
prop = IfcStore.file.get_property(element, pset_name, property_name)
if not prop: psets = get_psets(element)
if not pset_name in psets:
assert False
pset = psets[pset_name]
if not property_name in pset:
assert False
prop = pset[property_name]
# get_psets returns just strings
if not re.search(pattern, prop):
assert False assert False
# For now, we only check single values
if prop.is_a("IfcPropertySingleValue"):
if not (prop.NominalValue and re.search(pattern, prop.NominalValue.wrappedValue)):
assert False
def eleclass_has_property_in_pset( def eleclass_has_property_in_pset(
+1
View File
@@ -2,6 +2,7 @@ import datetime
import json import json
import os import os
import pystache import pystache
import sys
from bimtester.lang import _ from bimtester.lang import _