Debian Codegraph @

src/ifcbimtester/bimtester/features/steps/element_classes/en.py

raw
1 # BIMTester - OpenBIM Auditing Tool
2 # Copyright (C) 2021 Dion Moult <[email protected]>
3 #
4 # This file is part of BIMTester.
5 #
6 # BIMTester is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # BIMTester is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with BIMTester. If not, see <http://www.gnu.org/licenses/>.
18
19 from behave import step
20
21 from bimtester import util
22 from bimtester.ifc import IfcStore
23 from bimtester.lang import _
24
25
26 @step('The element "{guid}" is an "{ifc_class}" only')
27 def step_impl(context, guid, ifc_class):
28 element = util.assert_guid(IfcStore.file, guid)
29 util.assert_type(element, ifc_class, is_exact=True)
30
31
32 @step('The element "{guid}" is an "{ifc_class}"')
33 def step_impl(context, guid, ifc_class):
34 element = util.assert_guid(IfcStore.file, guid)
35 util.assert_type(element, ifc_class)
36
37
38 @step('The element "{guid}" is further defined as a "{predefined_type}"')
39 def step_impl(context, guid, predefined_type):
40 element = util.assert_guid(IfcStore.file, guid)
41 if (
42 hasattr(element, "PredefinedType")
43 and element.PredefinedType == "USERDEFINED"
44 and hasattr(element, "ObjectType")
45 ):
46 util.assert_attribute(element, "ObjectType", predefined_type)
47 elif hasattr(element, "PredefinedType"):
48 util.assert_attribute(element, "PredefinedType", predefined_type)
49 else:
50 assert False, _("The element {} does not have a PredefinedType or ObjectType attribute").format(element)
51
52
53 @step('The element "{guid}" should not exist because "{reason}"')
54 def step_impl(context, guid, reason):
55 try:
56 element = IfcStore.file.by_id(guid)
57 except:
58 return
59 assert False, _("This element {} should be reevaluated.").format(element)