11import ifcopenshell
2- from behave import given , when , then , step
2+ from behave import step
33
44class IfcFile (object ):
55 file = None
@@ -31,47 +31,47 @@ def get_property(cls, element, pset_name, property_name):
3131 return prop
3232
3333
34- @given ( 'the IFC file "{file}"' )
34+ @step ( 'The IFC file "{file}" must be provided ' )
3535def step_impl (context , file ):
3636 IfcFile .load (file )
3737
3838
39- @given ( 'the IFC file "{file}" exists ' )
39+ @step ( 'The IFC file "{file}" is exempt from being provided ' )
4040def step_impl (context , file ):
4141 pass
4242
4343
44- @then ( 'the file should be an {schema} file ' )
44+ @step ( 'IFC data must use the {schema} schema ' )
4545def step_impl (context , schema ):
4646 assert IfcFile .get ().schema == schema
4747
4848
49- @then ('the element {id} is an {ifc_class}' )
49+ @step ('the element {id} is an {ifc_class}' )
5050def step_impl (context , id , ifc_class ):
5151 assert IfcFile .get ().by_id (id ).is_a (ifc_class )
5252
5353
54- @then ('the element {id} should not exist because {reason}' )
54+ @step ('the element {id} should not exist because {reason}' )
5555def step_impl (context , id , reason ):
5656 assert not IfcFile .get ().by_id (id )
5757
5858
59- @then ( 'the file is exempt from auditing because {reason}' )
59+ @step ( 'No further requirements are specified because {reason}' )
6060def step_impl (context , reason ):
6161 pass
6262
6363
64- @given (u'there is at least one {ifc_class} element' )
64+ @step (u'there is at least one {ifc_class} element' )
6565def step_impl (context , ifc_class ):
6666 assert len (IfcFile .get ().by_type (ifc_class )) >= 1
6767
6868
69- @then (u'there are no {ifc_class} elements because {reason}' )
69+ @step (u'there are no {ifc_class} elements because {reason}' )
7070def step_impl (context , ifc_class , reason ):
7171 assert len (IfcFile .get ().by_type (ifc_class )) == 0
7272
7373
74- @then ('all {ifc_class} elements have a name matching the pattern "{pattern}"' )
74+ @step ('all {ifc_class} elements have a name matching the pattern "{pattern}"' )
7575def step_impl (context , ifc_class , pattern ):
7676 import re
7777 elements = IfcFile .get ().by_type (ifc_class )
@@ -80,7 +80,7 @@ def step_impl(context, ifc_class, pattern):
8080 assert False
8181
8282
83- @then ('all {ifc_class} elements have an {representation_class} representation' )
83+ @step ('all {ifc_class} elements have an {representation_class} representation' )
8484def step_impl (context , ifc_class , representation_class ):
8585 def is_item_a_representation (item , representation ):
8686 if '/' in representation :
@@ -109,15 +109,15 @@ def is_item_a_representation(item, representation):
109109 assert False
110110
111111use_step_matcher ('re' )
112- @then ('all (?P<ifc_class>.*) elements have an? (?P<attribute>.*) attribute' )
112+ @step ('all (?P<ifc_class>.*) elements have an? (?P<attribute>.*) attribute' )
113113def step_impl (context , ifc_class , attribute ):
114114 elements = IfcFile .get ().by_type (ifc_class )
115115 for element in elements :
116116 if not getattr (element , attribute ):
117117 assert False
118118
119119
120- @then ('all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property' )
120+ @step ('all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property' )
121121def step_impl (context , ifc_class , property_path ):
122122 pset_name , property_name = property_path .split ('.' )
123123 elements = IfcFile .get ().by_type (ifc_class )
@@ -126,7 +126,7 @@ def step_impl(context, ifc_class, property_path):
126126 assert False
127127
128128
129- @then ('all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property value matching the pattern "(?P<pattern>.*)"' )
129+ @step ('all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property value matching the pattern "(?P<pattern>.*)"' )
130130def step_impl (context , ifc_class , property_path , pattern ):
131131 import re
132132 pset_name , property_name = property_path .split ('.' )
@@ -142,7 +142,7 @@ def step_impl(context, ifc_class, property_path, pattern):
142142 assert False
143143
144144
145- @then ('all (?P<ifc_class>.*) elements have an? (?P<attribute>.*) matching the pattern "(?P<pattern>.*)"' )
145+ @step ('all (?P<ifc_class>.*) elements have an? (?P<attribute>.*) matching the pattern "(?P<pattern>.*)"' )
146146def step_impl (context , ifc_class , attribute , pattern ):
147147 import re
148148 elements = IfcFile .get ().by_type (ifc_class )
@@ -152,7 +152,7 @@ def step_impl(context, ifc_class, attribute, pattern):
152152 assert re .search (pattern , value )
153153
154154
155- @then ('all (?P<ifc_class>.*) elements have an? (?P<attributes>.*) taken from the list in "(?P<list_file>.*)"' )
155+ @step ('all (?P<ifc_class>.*) elements have an? (?P<attributes>.*) taken from the list in "(?P<list_file>.*)"' )
156156def step_impl (context , ifc_class , attributes , list_file ):
157157 import csv
158158 values = []
@@ -172,7 +172,7 @@ def step_impl(context, ifc_class, attributes, list_file):
172172
173173
174174use_step_matcher ('parse' )
175- @then ('all {ifc_class} elements have a {qto_name}.{quantity_name} quantity' )
175+ @step ('all {ifc_class} elements have a {qto_name}.{quantity_name} quantity' )
176176def step_impl (context , ifc_class , qto_name , quantity_name ):
177177 elements = IfcFile .get ().by_type (ifc_class )
178178 for element in elements :
@@ -187,7 +187,7 @@ def step_impl(context, ifc_class, qto_name, quantity_name):
187187 if not is_successful :
188188 assert False
189189
190- @then (u'the project should have geolocation data' )
190+ @step (u'the project should have geolocation data' )
191191def step_impl (context ):
192192 if IfcFile .get ().schema == 'IFC2X3' :
193193 for site in IfcFile .get ().by_type ('IfcSite' ):
@@ -203,7 +203,7 @@ def step_impl(context):
203203 return
204204 assert False
205205
206- @then (u'the project geolocation uses the "{crs_name}" CRS' )
206+ @step (u'the project geolocation uses the "{crs_name}" CRS' )
207207def step_impl (context , crs_name ):
208208 if IfcFile .get ().schema == 'IFC2X3' :
209209 for site in IfcFile .get ().by_type ('IfcSite' ):
@@ -214,24 +214,24 @@ def step_impl(context, crs_name):
214214
215215
216216use_step_matcher ('re' )
217- @then (u'the geolocated datum has an? (?P<attribute>.*) of "(?P<value>.*)"' )
217+ @step (u'the geolocated datum has an? (?P<attribute>.*) of "(?P<value>.*)"' )
218218def step_impl (context , attribute , value ):
219219 if IfcFile .get ().schema == 'IFC2X3' :
220220 site = IfcFile .get ().by_type ('IfcSite' )[0 ]
221221 actual_value = IfcFile .get_property (site , 'EPset_MapConversion' , attribute ).NominalValue .wrappedValue
222222 else :
223223 actual_value = getattr (IfcFile .get ().by_id (IfcFile .bookmarks ['geolocation' ]), attribute )
224- assert str (actual_value ) == value , f'The value was { actual_value } '
224+ assert str (actual_value ) == value , f'The value was { actual_value } '
225225
226226
227227use_step_matcher ('parse' )
228- @then (u'the project has a {attribute_name} attribute with a value of "{attribute_value}"' )
228+ @step (u'the project has a {attribute_name} attribute with a value of "{attribute_value}"' )
229229def step_impl (context , attribute_name , attribute_value ):
230230 project = IfcFile .get ().by_type ('IfcProject' )[0 ]
231231 assert getattr (project , attribute_name ) == attribute_value
232232
233233
234- @then (u'there is an {ifc_class} element with a {attribute_name} attribute with a value of "{attribute_value}"' )
234+ @step (u'there is an {ifc_class} element with a {attribute_name} attribute with a value of "{attribute_value}"' )
235235def step_impl (context , ifc_class , attribute_name , attribute_value ):
236236 elements = IfcFile .get ().by_type (ifc_class )
237237 for element in elements :
@@ -241,7 +241,7 @@ def step_impl(context, ifc_class, attribute_name, attribute_value):
241241 assert False
242242
243243
244- @then (u'all buildings have an address' )
244+ @step (u'all buildings have an address' )
245245def step_impl (context ):
246246 for building in IfcFile .get ().by_type ('IfcBuilding' ):
247247 if not building .BuildingAddress :
0 commit comments