mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Tuning feature tests
This commit is contained in:
@@ -261,19 +261,6 @@ def the_object_name_exists(name) -> bpy.types.Object:
|
||||
assert False, f'The object "{name}" does not exist'
|
||||
return obj
|
||||
|
||||
@then(parsers.parse('the object "{name}" does not exist'))
|
||||
def the_object_name_not_exists(name):
|
||||
obj = bpy.data.objects.get(name)
|
||||
if obj:
|
||||
assert False, f'The object "{name}" exists'
|
||||
assert True
|
||||
|
||||
@then(parsers.parse('objects starting with "{name}" do not exist'))
|
||||
def objects_not_exist_starting_with(name):
|
||||
objs = [obj for obj in bpy.data.objects if obj.name.startswith(name)]
|
||||
if len(objs) > 0:
|
||||
assert False, f'{len(objs)} objects starting with "{name}" exist'
|
||||
assert True
|
||||
|
||||
@then(parsers.parse('the object "{name1}" and "{name2}" are different elements'))
|
||||
def the_object_name1_and_name2_are_different_elements(name1, name2):
|
||||
@@ -520,7 +507,16 @@ def the_collection_name1_is_in_the_collection_name2(name1, name2):
|
||||
|
||||
@then(parsers.parse('the object "{name}" does not exist'))
|
||||
def the_object_name_does_not_exist(name):
|
||||
assert bpy.data.objects.get(name) is None, "Object exists"
|
||||
obj = bpy.data.objects.get(name)
|
||||
assert obj is None or len(obj.users_collection) == 0, "Object exists"
|
||||
|
||||
|
||||
@then(parsers.parse('objects starting with "{name}" do not exist'))
|
||||
def objects_not_exist_starting_with(name):
|
||||
objs = [obj for obj in bpy.data.objects if obj.name.startswith(name) and len(obj.users_collection) > 0]
|
||||
if len(objs) > 0:
|
||||
assert False, f'{len(objs)} objects starting with "{name}" exist'
|
||||
assert True
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" is at "{location}"'))
|
||||
@@ -579,7 +575,7 @@ def the_object_name_has_no_modifiers(name):
|
||||
|
||||
@then(parsers.parse('the construction type "{constr_class}"/"{constr_type}" has a preview'))
|
||||
def the_construction_type_has_a_preview(constr_class, constr_type):
|
||||
if "preview_constr_types" not in AuthoringData:
|
||||
if "preview_constr_types" not in AuthoringData.data:
|
||||
assert False, 'There are no previews loaded'
|
||||
preview_constr_types = AuthoringData.data["preview_constr_types"]
|
||||
if constr_class not in preview_constr_types:
|
||||
@@ -593,7 +589,7 @@ def the_construction_type_has_a_preview(constr_class, constr_type):
|
||||
if 'icon_id' not in preview_data:
|
||||
assert False, f'Construction type {constr_class}/{constr_type} has a preview, but no assigned icon_id'
|
||||
icon_id = preview_data["icon_id"]
|
||||
if type(icon_id) is not int:
|
||||
if not isinstance(icon_id, int):
|
||||
assert False, f'Construction type {constr_class}/{constr_type} has an invalid icon_id {icon_id}'
|
||||
if icon_id == 0:
|
||||
assert False, f'Construction type {constr_class}/{constr_type} has the default null value for icon_id'
|
||||
@@ -602,7 +598,7 @@ def the_construction_type_has_a_preview(constr_class, constr_type):
|
||||
|
||||
@then(parsers.parse('all construction types for "{constr_class}" have a preview'))
|
||||
def all_construction_types_have_a_preview(constr_class):
|
||||
if "preview_constr_types" not in AuthoringData:
|
||||
if "preview_constr_types" not in AuthoringData.data:
|
||||
assert False, 'There are no previews loaded'
|
||||
preview_constr_types = AuthoringData.data["preview_constr_types"]
|
||||
if constr_class not in preview_constr_types:
|
||||
@@ -615,17 +611,32 @@ def all_construction_types_have_a_preview(constr_class):
|
||||
@given("I load the demo construction library")
|
||||
@when("I load the demo construction library")
|
||||
def i_add_a_construction_library():
|
||||
lib_path = '../../blenderbim/bim/data/libraries/IFC4 Demo Library.ifc'
|
||||
lib_path = './blenderbim/bim/data/libraries/IFC4 Demo Library.ifc'
|
||||
bpy.ops.bim.select_library_file(filepath=lib_path, append_all=True)
|
||||
|
||||
|
||||
@given("I make an asset from the selected construction type")
|
||||
@when("I make an asset from the selected construction type")
|
||||
def i_assetize_from_selected_constr_type():
|
||||
AuthoringData.assetize_constr_type_from_selection()
|
||||
@given("I display the Construction Type Browser")
|
||||
@when("I display the Construction Type Browser")
|
||||
def i_display_the_construction_type_browser():
|
||||
bpy.ops.bim.display_constr_types()
|
||||
|
||||
|
||||
@given("I make assets from the selected construction class")
|
||||
@when("I make assets from the selected construction class")
|
||||
def i_assetize_from_selected_constr_class():
|
||||
AuthoringData.assetize_constr_class()
|
||||
@given("I preview only one asset on the Construction Type Browser")
|
||||
@when("I preview only one asset on the Construction Type Browser")
|
||||
def i_preview_one_construction_type():
|
||||
bpy.context.scene.BIMModelProperties.unfold_relating_type = False
|
||||
|
||||
|
||||
@given("I preview all available assets on the Construction Type Browser")
|
||||
@when("I preview all available assets on the Construction Type Browser")
|
||||
def i_preview_all_construction_types():
|
||||
bpy.context.scene.BIMModelProperties.unfold_relating_type = True
|
||||
|
||||
|
||||
@given("I select the active construction type")
|
||||
@when("I select the active construction type")
|
||||
def i_select_the_active_construction_type():
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
bpy.ops.bim.select_construction_type(
|
||||
constr_class=props.constr_class_browser, constr_type_id=props.constr_type_id_browser
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user