mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 20:00:53 +00:00
tests(bevy_components): migrating tests to new apis
This commit is contained in:
parent
ebf82b902f
commit
e7e680b92c
@ -110,6 +110,7 @@ def do_object_custom_properties_have_missing_metadata(object):
|
|||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
def upsert_bevy_component(object, long_name, value):
|
def upsert_bevy_component(object, long_name, value):
|
||||||
if not 'bevy_components' in object:
|
if not 'bevy_components' in object:
|
||||||
object['bevy_components'] = '{}'
|
object['bevy_components'] = '{}'
|
||||||
|
@ -238,7 +238,7 @@ class OT_rename_component(Operator):
|
|||||||
# attempt conversion
|
# attempt conversion
|
||||||
long_name = new_name
|
long_name = new_name
|
||||||
component_definition = type_infos[long_name]
|
component_definition = type_infos[long_name]
|
||||||
add_component_to_object(object, component_definition, get_bevy_component_value_by_long_name(new_name))
|
add_component_to_object(object, component_definition, get_bevy_component_value_by_long_name(object, new_name))
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
if '__disable__update' in object:
|
if '__disable__update' in object:
|
||||||
del object["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
del object["__disable__update"] # make sure custom properties are updateable afterwards, even in the case of failure
|
||||||
|
@ -5,6 +5,7 @@ from ..propGroups.conversions_to_prop_group import property_group_value_from_cus
|
|||||||
from ..propGroups.conversions_from_prop_group import property_group_value_to_custom_property_value
|
from ..propGroups.conversions_from_prop_group import property_group_value_to_custom_property_value
|
||||||
from .component_values_shuffler import component_values_shuffler
|
from .component_values_shuffler import component_values_shuffler
|
||||||
from .expected_component_values import (expected_custom_property_values, expected_custom_property_values_randomized)
|
from .expected_component_values import (expected_custom_property_values, expected_custom_property_values_randomized)
|
||||||
|
from ..components.metadata import get_bevy_component_value_by_long_name, get_bevy_components, upsert_bevy_component
|
||||||
|
|
||||||
from .setup_data import setup_data
|
from .setup_data import setup_data
|
||||||
|
|
||||||
@ -25,25 +26,24 @@ def test_components_should_generate_correct_custom_properties(setup_data):
|
|||||||
|
|
||||||
for long_name in type_infos:
|
for long_name in type_infos:
|
||||||
definition = type_infos[long_name]
|
definition = type_infos[long_name]
|
||||||
component_type = definition["long_name"]
|
long_name = definition["long_name"]
|
||||||
short_name = definition["short_name"]
|
|
||||||
is_component = definition['isComponent'] if "isComponent" in definition else False
|
is_component = definition['isComponent'] if "isComponent" in definition else False
|
||||||
if not is_component:
|
if not is_component:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
addable_components.append(component_type)
|
addable_components.append(long_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
add_component_operator(component_type=component_type)
|
add_component_operator(component_type=long_name)
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
added_components.append(component_type)
|
added_components.append(long_name)
|
||||||
custom_property_values[short_name] = object[short_name]
|
custom_property_values[long_name] = get_bevy_component_value_by_long_name(object, long_name)
|
||||||
assert object[short_name] == expected_custom_property_values[short_name]
|
assert get_bevy_component_value_by_long_name(object, long_name) == expected_custom_property_values[long_name]
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
errors.append(error)
|
errors.append(error)
|
||||||
@ -74,30 +74,29 @@ def test_components_should_generate_correct_custom_properties_with_randomized_va
|
|||||||
|
|
||||||
for long_name in type_infos:
|
for long_name in type_infos:
|
||||||
definition = type_infos[long_name]
|
definition = type_infos[long_name]
|
||||||
component_type = definition["long_name"]
|
long_name = definition["long_name"]
|
||||||
short_name = definition["short_name"]
|
|
||||||
is_component = definition['isComponent'] if "isComponent" in definition else False
|
is_component = definition['isComponent'] if "isComponent" in definition else False
|
||||||
if not is_component:
|
if not is_component:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
addable_components.append(component_type)
|
addable_components.append(long_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
add_component_operator(component_type=component_type)
|
add_component_operator(component_type=long_name)
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
component_values_shuffler(seed= 10, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 10, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
added_components.append(component_type)
|
added_components.append(long_name)
|
||||||
custom_property_values[short_name] = object[short_name]
|
custom_property_values[long_name] = get_bevy_component_value_by_long_name(object, long_name)
|
||||||
assert object[short_name] == expected_custom_property_values_randomized[short_name]
|
assert get_bevy_component_value_by_long_name(object, long_name) == expected_custom_property_values_randomized[long_name]
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
errors.append(error)
|
errors.append(error)
|
||||||
error_components.append(short_name)
|
error_components.append(long_name)
|
||||||
|
|
||||||
pp = pprint.PrettyPrinter(depth=14, width=120)
|
pp = pprint.PrettyPrinter(depth=14, width=120)
|
||||||
print("CUSTOM PROPERTY VALUES")
|
print("CUSTOM PROPERTY VALUES")
|
||||||
@ -123,42 +122,41 @@ def test_components_should_generate_correct_propertyGroup_values_from_custom_pro
|
|||||||
|
|
||||||
for long_name in type_infos:
|
for long_name in type_infos:
|
||||||
definition = type_infos[long_name]
|
definition = type_infos[long_name]
|
||||||
component_type = definition["long_name"]
|
long_name = definition["long_name"]
|
||||||
short_name = definition["short_name"]
|
|
||||||
is_component = definition['isComponent'] if "isComponent" in definition else False
|
is_component = definition['isComponent'] if "isComponent" in definition else False
|
||||||
if not is_component:
|
if not is_component:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
addable_components.append(component_type)
|
addable_components.append(long_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
add_component_operator(component_type=component_type)
|
add_component_operator(component_type=long_name)
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
added_components.append(component_type)
|
added_components.append(long_name)
|
||||||
# randomise values
|
# randomise values
|
||||||
component_values_shuffler(seed= 10, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 10, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
custom_property_value = object[short_name]
|
custom_property_value = object[long_name]
|
||||||
|
|
||||||
# first check if custom property value matches what we expect
|
# first check if custom property value matches what we expect
|
||||||
assert custom_property_value == expected_custom_property_values_randomized[short_name]
|
assert custom_property_value == expected_custom_property_values_randomized[long_name]
|
||||||
|
|
||||||
# we update propgroup values from custom property values
|
# we update propgroup values from custom property values
|
||||||
property_group_value_from_custom_property_value(propertyGroup, definition, registry, custom_property_value, nesting = [])
|
property_group_value_from_custom_property_value(propertyGroup, definition, registry, custom_property_value, nesting = [])
|
||||||
# and then generate it back
|
# and then generate it back
|
||||||
custom_property_value_regen = property_group_value_to_custom_property_value(propertyGroup, definition, registry, None)
|
custom_property_value_regen = property_group_value_to_custom_property_value(propertyGroup, definition, registry, None)
|
||||||
assert custom_property_value_regen == expected_custom_property_values_randomized[short_name]
|
assert custom_property_value_regen == expected_custom_property_values_randomized[long_name]
|
||||||
|
|
||||||
# custom_property_values[short_name] = object[short_name]
|
# custom_property_values[long_name] = object[long_name]
|
||||||
#assert object[short_name] == expected_custom_property_values[short_name]
|
#assert object[long_name] == expected_custom_property_values[long_name]
|
||||||
#print("CUSTOM PROPERTY ", object[short_name])
|
#print("CUSTOM PROPERTY ", object[long_name])
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
errors.append(error)
|
errors.append(error)
|
||||||
failing_components.append(short_name)
|
failing_components.append(long_name)
|
||||||
|
|
||||||
for index, error in enumerate(errors):
|
for index, error in enumerate(errors):
|
||||||
print("ERROR", error, failing_components[index])
|
print("ERROR", error, failing_components[index])
|
||||||
@ -180,25 +178,24 @@ def test_remove_components(setup_data):
|
|||||||
|
|
||||||
for long_name in type_infos:
|
for long_name in type_infos:
|
||||||
definition = type_infos[long_name]
|
definition = type_infos[long_name]
|
||||||
component_type = definition["long_name"]
|
long_name = definition["long_name"]
|
||||||
short_name = definition["short_name"]
|
|
||||||
is_component = definition['isComponent'] if "isComponent" in definition else False
|
is_component = definition['isComponent'] if "isComponent" in definition else False
|
||||||
if not is_component:
|
if not is_component:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
addable_components.append(component_type)
|
addable_components.append(long_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
add_component_operator(component_type=component_type)
|
add_component_operator(component_type=long_name)
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
object = bpy.context.object
|
object = bpy.context.object
|
||||||
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
# print("propertyGroup", propertyGroup, propertyGroup.field_names)
|
# print("propertyGroup", propertyGroup, propertyGroup.field_names)
|
||||||
added_components.append(component_type)
|
added_components.append(long_name)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
errors.append(error)
|
errors.append(error)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
@ -206,8 +203,8 @@ def test_remove_components(setup_data):
|
|||||||
# now test component removal
|
# now test component removal
|
||||||
errors.clear()
|
errors.clear()
|
||||||
remove_component_operator = bpy.ops.object.remove_bevy_component
|
remove_component_operator = bpy.ops.object.remove_bevy_component
|
||||||
for component_type in added_components:
|
for long_name in added_components:
|
||||||
component_name = type_infos[component_type]["short_name"]
|
component_name = type_infos[long_name]
|
||||||
try:
|
try:
|
||||||
remove_component_operator(component_name=component_name)
|
remove_component_operator(component_name=component_name)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
@ -220,24 +217,23 @@ def test_copy_paste_components(setup_data):
|
|||||||
registry.schemaPath = setup_data["schema_path"]
|
registry.schemaPath = setup_data["schema_path"]
|
||||||
bpy.ops.object.reload_registry()
|
bpy.ops.object.reload_registry()
|
||||||
|
|
||||||
short_name = "BasicTest"
|
long_name = "BasicTest"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
|
||||||
|
|
||||||
# SOURCE object setup
|
# SOURCE object setup
|
||||||
add_component_operator = bpy.ops.object.add_bevy_component
|
add_component_operator = bpy.ops.object.add_bevy_component
|
||||||
add_component_operator(component_type=component_type)
|
add_component_operator(component_type=long_name)
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
object = context.object
|
object = context.object
|
||||||
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
setattr(propertyGroup, propertyGroup.field_names[0], 25.0)
|
setattr(propertyGroup, propertyGroup.field_names[0], 25.0)
|
||||||
|
|
||||||
copy_component_operator = bpy.ops.object.copy_bevy_component
|
copy_component_operator = bpy.ops.object.copy_bevy_component
|
||||||
copy_component_operator(source_component_name=short_name, source_object_name=object.name)
|
copy_component_operator(source_component_name=long_name, source_object_name=object.name)
|
||||||
|
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
# TARGET object
|
# TARGET object
|
||||||
@ -246,7 +242,7 @@ def test_copy_paste_components(setup_data):
|
|||||||
# change name
|
# change name
|
||||||
new_cube.name = "TargetCube"
|
new_cube.name = "TargetCube"
|
||||||
target_components_metadata = new_cube.components_meta.components
|
target_components_metadata = new_cube.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
|
|
||||||
# first check that there is no component currently
|
# first check that there is no component currently
|
||||||
assert component_meta == None
|
assert component_meta == None
|
||||||
@ -255,7 +251,7 @@ def test_copy_paste_components(setup_data):
|
|||||||
paste_component_operator()
|
paste_component_operator()
|
||||||
|
|
||||||
target_components_metadata = new_cube.components_meta.components
|
target_components_metadata = new_cube.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
|
|
||||||
# now after pasting to the new object, it should have component meta
|
# now after pasting to the new object, it should have component meta
|
||||||
assert component_meta != None
|
assert component_meta != None
|
||||||
|
@ -6,17 +6,16 @@ def test_blend(setup_data):
|
|||||||
registry.schemaPath = setup_data["schema_path"]
|
registry.schemaPath = setup_data["schema_path"]
|
||||||
bpy.ops.object.reload_registry()
|
bpy.ops.object.reload_registry()
|
||||||
|
|
||||||
short_name = "BasicTest"
|
long_name = "bevy_example::test_components::BasicTest"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
|
||||||
|
|
||||||
add_component_operator = bpy.ops.object.add_bevy_component
|
add_component_operator = bpy.ops.object.add_bevy_component
|
||||||
add_component_operator(component_type=component_type)
|
add_component_operator(component_type=long_name)
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
object = bpy.context.object
|
object = bpy.context.object
|
||||||
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import bpy
|
|||||||
import pprint
|
import pprint
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from ..components.metadata import get_bevy_components, upsert_bevy_component
|
||||||
|
|
||||||
from .setup_data import setup_data
|
from .setup_data import setup_data
|
||||||
|
|
||||||
# small helpers
|
# small helpers
|
||||||
@ -15,7 +17,7 @@ def get_component_metadata(object, component_name):
|
|||||||
def get_component_propGroup(registry, component_name, component_meta):
|
def get_component_propGroup(registry, component_name, component_meta):
|
||||||
# component_type = registry.short_names_to_long_names[component_name]
|
# component_type = registry.short_names_to_long_names[component_name]
|
||||||
# add_component_operator = bpy.ops.object.add_bevy_component
|
# add_component_operator = bpy.ops.object.add_bevy_component
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(component_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(component_name)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
return propertyGroup
|
return propertyGroup
|
||||||
|
|
||||||
@ -29,9 +31,9 @@ def test_rename_component_single_unit_struct(setup_data):
|
|||||||
object = bpy.context.object
|
object = bpy.context.object
|
||||||
|
|
||||||
|
|
||||||
source_component_name = "SomeOldUnitStruct"
|
source_component_name = "bevy_example::test_components::SomeOldUnitStruct"
|
||||||
target_component_name = "UnitTest"
|
target_component_name = "bevy_example::test_components::UnitTest"
|
||||||
object[source_component_name] = '()'
|
upsert_bevy_component(object, source_component_name, '()')
|
||||||
|
|
||||||
rename_component_operator(original_name=source_component_name, new_name=target_component_name, target_objects=json.dumps([object.name]))
|
rename_component_operator(original_name=source_component_name, new_name=target_component_name, target_objects=json.dumps([object.name]))
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ def test_rename_component_single_unit_struct(setup_data):
|
|||||||
is_new_component_in_object = target_component_name in object
|
is_new_component_in_object = target_component_name in object
|
||||||
assert is_old_component_in_object == False
|
assert is_old_component_in_object == False
|
||||||
assert is_new_component_in_object == True
|
assert is_new_component_in_object == True
|
||||||
assert object[target_component_name] == '()'
|
assert get_bevy_components(object, target_component_name) == '()'
|
||||||
assert get_component_propGroup(registry, target_component_name, get_component_metadata(object, target_component_name)) != None
|
assert get_component_propGroup(registry, target_component_name, get_component_metadata(object, target_component_name)) != None
|
||||||
|
|
||||||
|
|
||||||
@ -52,8 +54,8 @@ def test_rename_component_single_complex_struct(setup_data):
|
|||||||
object = bpy.context.object
|
object = bpy.context.object
|
||||||
|
|
||||||
|
|
||||||
source_component_name = "ProxyCollider"
|
source_component_name = "bevy_example::test_components::ProxyCollider"
|
||||||
target_component_name = "Collider"
|
target_component_name = "bevy_example::test_components::Collider"
|
||||||
object[source_component_name] = 'Capsule(Vec3(x:1.0, y:2.0, z:0.0), Vec3(x:0.0, y:0.0, z:0.0), 3.0)'
|
object[source_component_name] = 'Capsule(Vec3(x:1.0, y:2.0, z:0.0), Vec3(x:0.0, y:0.0, z:0.0), 3.0)'
|
||||||
|
|
||||||
rename_component_operator(original_name=source_component_name, new_name=target_component_name, target_objects=json.dumps([object.name]))
|
rename_component_operator(original_name=source_component_name, new_name=target_component_name, target_objects=json.dumps([object.name]))
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from .component_values_shuffler import component_values_shuffler
|
from .component_values_shuffler import component_values_shuffler
|
||||||
|
from ..components.metadata import get_bevy_component_value_by_long_name, get_bevy_components, upsert_bevy_component
|
||||||
from .setup_data import setup_data
|
from .setup_data import setup_data
|
||||||
|
|
||||||
def test_shuffler(setup_data):
|
def test_shuffler(setup_data):
|
||||||
@ -12,17 +13,15 @@ def test_shuffler(setup_data):
|
|||||||
|
|
||||||
add_component_operator = bpy.ops.object.add_bevy_component
|
add_component_operator = bpy.ops.object.add_bevy_component
|
||||||
|
|
||||||
short_name = "BasicTest"
|
long_name = "bevy_example::test_components::BasicTest"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
|
|
||||||
add_component_operator(component_type=component_type)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 10, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 10, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
assert getattr(propertyGroup, 'a') == 0.5714026093482971
|
assert getattr(propertyGroup, 'a') == 0.5714026093482971
|
||||||
@ -31,130 +30,121 @@ def test_shuffler(setup_data):
|
|||||||
|
|
||||||
|
|
||||||
# Testing a more complex component
|
# Testing a more complex component
|
||||||
short_name = "NestingTestLevel2"
|
long_name = "bevy_example::test_components::NestingTestLevel2"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
add_component_operator(component_type=component_type)
|
|
||||||
|
|
||||||
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
print("propertyGroup", object[short_name])
|
#print("propertyGroup", object[long_name])
|
||||||
# cheating / making things easier for us for complex types: we use the custom property value
|
# cheating / making things easier for us for complex types: we use the custom property value
|
||||||
assert object[short_name] == '(basic: (a: 0.5219839215278625, b: 38, c: "ljfywwrv"), color: (Rgba(red:0.2782765030860901, green:0.9174930453300476, blue:0.24890311062335968, alpha:0.815186083316803)), colors_list: ([Rgba(red:0.2523837685585022, green:0.5016026496887207, blue:0.317435085773468, alpha:0.8463277816772461), Rgba(red:0.945193886756897, green:0.4015909433364868, blue:0.9984470009803772, alpha:0.06219279021024704)]), enable: true, enum_inner: Wood, nested: (vec: (Vec3(x:0.1509154736995697, y:0.7055686116218567, z:0.5588918924331665))), text: "vgkrdwuc", toggle: (false))'
|
assert get_bevy_component_value_by_long_name(object, long_name) == '(basic: (a: 0.5219839215278625, b: 38, c: "ljfywwrv"), color: (Rgba(red:0.2782765030860901, green:0.9174930453300476, blue:0.24890311062335968, alpha:0.815186083316803)), colors_list: ([Rgba(red:0.2523837685585022, green:0.5016026496887207, blue:0.317435085773468, alpha:0.8463277816772461), Rgba(red:0.945193886756897, green:0.4015909433364868, blue:0.9984470009803772, alpha:0.06219279021024704)]), enable: true, enum_inner: Wood, nested: (vec: (Vec3(x:0.1509154736995697, y:0.7055686116218567, z:0.5588918924331665))), text: "vgkrdwuc", toggle: (false))'
|
||||||
|
|
||||||
|
|
||||||
# And another complex component
|
# And another complex component
|
||||||
short_name = "EnumComplex"
|
long_name = "bevy_example::test_components::EnumComplex"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
add_component_operator(component_type=component_type)
|
|
||||||
|
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
print("propertyGroup", object[short_name])
|
print("propertyGroup", get_bevy_component_value_by_long_name(object, long_name))
|
||||||
# cheating / making things easier for us for complex types: we use the custom property value
|
# cheating / making things easier for us for complex types: we use the custom property value
|
||||||
assert object[short_name] == 'StructLike(a: 0.41416797041893005, b: 38, c: "ljfywwrv")'
|
assert get_bevy_component_value_by_long_name(object, long_name) == 'StructLike(a: 0.41416797041893005, b: 38, c: "ljfywwrv")'
|
||||||
|
|
||||||
# And another complex component
|
# And another complex component
|
||||||
short_name = "AnimationPlayer"
|
long_name = "bevy_example::test_components::AnimationPlayer"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
add_component_operator(component_type=component_type)
|
|
||||||
|
|
||||||
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
print("propertyGroup", object[short_name])
|
print("propertyGroup", get_bevy_component_value_by_long_name(object, long_name))
|
||||||
# cheating / making things easier for us for complex types: we use the custom property value
|
# cheating / making things easier for us for complex types: we use the custom property value
|
||||||
assert object[short_name] == '(animation: "", paused: true)'
|
assert get_bevy_component_value_by_long_name(object, long_name) == '(animation: "", paused: true)'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# And another complex component
|
# And another complex component
|
||||||
short_name = "VecOfColors"
|
long_name = "bevy_example::test_components::VecOfColors"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
add_component_operator(component_type=component_type)
|
|
||||||
|
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
print("propertyGroup", object[short_name])
|
print("propertyGroup", get_bevy_component_value_by_long_name(object, long_name))
|
||||||
# cheating / making things easier for us for complex types: we use the custom property value
|
# cheating / making things easier for us for complex types: we use the custom property value
|
||||||
assert object[short_name] == '([Rgba(red:0.8066907525062561, green:0.9604947566986084, blue:0.2896253764629364, alpha:0.766107439994812), Rgba(red:0.7042198777198792, green:0.6613830327987671, blue:0.11016204953193665, alpha:0.02693677879869938)])'
|
assert get_bevy_component_value_by_long_name(object, long_name) == '([Rgba(red:0.8066907525062561, green:0.9604947566986084, blue:0.2896253764629364, alpha:0.766107439994812), Rgba(red:0.7042198777198792, green:0.6613830327987671, blue:0.11016204953193665, alpha:0.02693677879869938)])'
|
||||||
|
|
||||||
|
|
||||||
# And another complex component
|
# And another complex component
|
||||||
short_name = "VecOfF32s"
|
long_name = "bevy_example::test_components::VecOfF32s"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
add_component_operator(component_type=component_type)
|
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
print("propertyGroup", object[short_name])
|
print("propertyGroup", get_bevy_component_value_by_long_name(object, long_name))
|
||||||
# cheating / making things easier for us for complex types: we use the custom property value
|
# cheating / making things easier for us for complex types: we use the custom property value
|
||||||
assert object[short_name] == '([0.8066907525062561, 0.9604947566986084])'
|
assert get_bevy_component_value_by_long_name(object, long_name) == '([0.8066907525062561, 0.9604947566986084])'
|
||||||
|
|
||||||
# And another complex component
|
# And another complex component
|
||||||
short_name = "SkinnedMesh"
|
long_name = "bevy_example::test_components::SkinnedMesh"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
add_component_operator(component_type=component_type)
|
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
print("propertyGroup", object[short_name])
|
print("propertyGroup", get_bevy_component_value_by_long_name(object, long_name))
|
||||||
# cheating / making things easier for us for complex types: we use the custom property value
|
# cheating / making things easier for us for complex types: we use the custom property value
|
||||||
assert object[short_name] == '(inverse_bindposes: Weak(Uuid(uuid: "73b3b118-7d01-4778-8bcc-4e79055f5d22")), joints: [0, 0])'
|
assert get_bevy_component_value_by_long_name(object, long_name) == '(inverse_bindposes: Weak(Uuid(uuid: "73b3b118-7d01-4778-8bcc-4e79055f5d22")), joints: [0, 0])'
|
||||||
|
|
||||||
|
|
||||||
# And another complex component
|
# And another complex component
|
||||||
short_name = "CameraRenderGraph"
|
long_name = "bevy_example::test_components::CameraRenderGraph"
|
||||||
component_type = registry.short_names_to_long_names[short_name]
|
add_component_operator(component_type=long_name)
|
||||||
add_component_operator(component_type=component_type)
|
|
||||||
|
|
||||||
property_group_name = registry.get_propertyGroupName_from_shortName(short_name)
|
property_group_name = registry.get_propertyGroupName_from_longName(long_name)
|
||||||
target_components_metadata = object.components_meta.components
|
target_components_metadata = object.components_meta.components
|
||||||
component_meta = next(filter(lambda component: component["long_name"] == short_name, target_components_metadata), None)
|
component_meta = next(filter(lambda component: component["long_name"] == long_name, target_components_metadata), None)
|
||||||
propertyGroup = getattr(component_meta, property_group_name, None)
|
propertyGroup = getattr(component_meta, property_group_name, None)
|
||||||
|
|
||||||
definition = type_infos[component_type]
|
definition = type_infos[long_name]
|
||||||
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
component_values_shuffler(seed= 17, property_group=propertyGroup, definition=definition, registry=registry)
|
||||||
|
|
||||||
print("propertyGroup", object[short_name])
|
print("propertyGroup", get_bevy_component_value_by_long_name(object, long_name))
|
||||||
# cheating / making things easier for us for complex types: we use the custom property value
|
# cheating / making things easier for us for complex types: we use the custom property value
|
||||||
assert object[short_name] == 'None'
|
assert get_bevy_component_value_by_long_name(object, long_name) == 'None'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user