2020-07-27 18:38:13 +10:00
|
|
|
from behave import step
|
2020-11-26 08:08:38 +01:00
|
|
|
|
|
|
|
|
from utils import assert_attribute
|
2020-07-27 18:38:13 +10:00
|
|
|
from utils import IfcFile
|
|
|
|
|
|
2020-11-01 19:22:49 +07:00
|
|
|
|
2020-08-10 14:38:46 +10:00
|
|
|
@step("The project must have an identifier of {guid}")
|
|
|
|
|
def step_impl(context, guid):
|
|
|
|
|
assert_attribute(IfcFile.get().by_type("IfcProject")[0], "GlobalId", guid)
|
|
|
|
|
|
|
|
|
|
|
2020-07-27 18:38:13 +10:00
|
|
|
@step('The project name, code, or short identifier must be "{value}"')
|
|
|
|
|
def step_impl(context, value):
|
2020-08-10 11:21:33 +10:00
|
|
|
assert_attribute(IfcFile.get().by_type("IfcProject")[0], "Name", value)
|
2020-07-27 18:38:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@step('The project must have a longer form name of "{value}"')
|
|
|
|
|
def step_impl(context, value):
|
2020-08-10 11:21:33 +10:00
|
|
|
assert_attribute(IfcFile.get().by_type("IfcProject")[0], "LongName", value)
|
2020-07-27 18:38:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@step('The project must be described as "{value}"')
|
|
|
|
|
def step_impl(context, value):
|
2020-08-10 11:21:33 +10:00
|
|
|
assert_attribute(IfcFile.get().by_type("IfcProject")[0], "Description", value)
|
2020-07-27 18:38:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@step('The project must be categorised under "{value}"')
|
|
|
|
|
def step_impl(context, value):
|
2020-08-10 11:21:33 +10:00
|
|
|
assert_attribute(IfcFile.get().by_type("IfcProject")[0], "ObjectType", value)
|
2020-07-27 18:38:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@step('The project must contain information about the "{value}" phase')
|
|
|
|
|
def step_impl(context, value):
|
2020-08-10 11:21:33 +10:00
|
|
|
assert_attribute(IfcFile.get().by_type("IfcProject")[0], "Phase", value)
|
2020-07-27 18:38:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@step("The project must contain 3D geometry representing the shape of objects")
|
|
|
|
|
def step_impl(context):
|
|
|
|
|
assert get_subcontext("Body", "Model", "MODEL_VIEW")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@step("The project must contain 3D geometry representing clearance zones")
|
|
|
|
|
def step_impl(context):
|
|
|
|
|
assert get_subcontext("Clearance", "Model", "MODEL_VIEW")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@step("The project must contain 3D geometry representing the center of gravity of objects")
|
|
|
|
|
def step_impl(context):
|
|
|
|
|
assert get_subcontext("CoG", "Model", "MODEL_VIEW")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@step("The project must contain 3D geometry representing the object bounding boxes")
|
|
|
|
|
def step_impl(context):
|
|
|
|
|
assert get_subcontext("Box", "Model", "MODEL_VIEW")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_subcontext(identifier, type, target_view):
|
|
|
|
|
project = IfcFile.get().by_type("IfcProject")[0]
|
|
|
|
|
for rep_context in project.RepresentationContexts:
|
|
|
|
|
for subcontext in rep_context.HasSubContexts:
|
|
|
|
|
if (
|
|
|
|
|
subcontext.ContextIdentifier == identifier
|
|
|
|
|
and subcontext.ContextType == type
|
|
|
|
|
and subcontext.TargetView == target_view
|
|
|
|
|
):
|
|
|
|
|
return True
|
|
|
|
|
assert False, "The subcontext with identifier {}, type {}, and target view {} could not be found".format(
|
|
|
|
|
identifier, type, target_view
|
|
|
|
|
)
|