refactor: fix tests
This commit is contained in:
@ -57,7 +57,7 @@ def resolve_from_root(data: dict, root: str, construct = True):
|
|||||||
if construct and not datablock_ref:
|
if construct and not datablock_ref:
|
||||||
name = self.data.get('name')
|
name = self.data.get('name')
|
||||||
logging.debug(f"Constructing {name}")
|
logging.debug(f"Constructing {name}")
|
||||||
datablock_ref = self._construct(data=self.data)
|
datablock_ref = self.construct(data=self.data)
|
||||||
|
|
||||||
if datablock_ref is not None:
|
if datablock_ref is not None:
|
||||||
setattr(datablock_ref, 'uuid', self.uuid)
|
setattr(datablock_ref, 'uuid', self.uuid)
|
||||||
|
@ -63,9 +63,7 @@ class BlMesh(ReplicatedDatablock):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def construct(data: dict) -> object:
|
def construct(data: dict) -> object:
|
||||||
instance = bpy.data.meshes.new(data.get("name"))
|
return bpy.data.meshes.new(data.get("name"))
|
||||||
instance.uuid = data.get("uuid")
|
|
||||||
return instance
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(data: dict, datablock: object):
|
def load(data: dict, datablock: object):
|
||||||
|
@ -469,10 +469,7 @@ class BlObject(ReplicatedDatablock):
|
|||||||
if data_type != 'EMPTY' and object_data is None:
|
if data_type != 'EMPTY' and object_data is None:
|
||||||
raise Exception(f"Fail to load object {data['name']})")
|
raise Exception(f"Fail to load object {data['name']})")
|
||||||
|
|
||||||
instance = bpy.data.objects.new(object_name, object_data)
|
return bpy.data.objects.new(object_name, object_data)
|
||||||
instance.uuid = data.get("uuid")
|
|
||||||
|
|
||||||
return instance
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(data: dict, datablock: object):
|
def load(data: dict, datablock: object):
|
||||||
|
@ -381,10 +381,7 @@ class BlScene(ReplicatedDatablock):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def construct(data: dict) -> object:
|
def construct(data: dict) -> object:
|
||||||
instance = bpy.data.scenes.new(data["name"])
|
return bpy.data.scenes.new(data["name"])
|
||||||
instance.uuid = data.get('uuid')
|
|
||||||
|
|
||||||
return instance
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(data: dict, datablock: object):
|
def load(data: dict, datablock: object):
|
||||||
|
@ -32,11 +32,11 @@ def test_action(clear_blend):
|
|||||||
|
|
||||||
# Test
|
# Test
|
||||||
implementation = BlAction()
|
implementation = BlAction()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.actions.remove(datablock)
|
bpy.data.actions.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -12,11 +12,11 @@ def test_armature(clear_blend):
|
|||||||
datablock = bpy.data.armatures[0]
|
datablock = bpy.data.armatures[0]
|
||||||
|
|
||||||
implementation = BlArmature()
|
implementation = BlArmature()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.armatures.remove(datablock)
|
bpy.data.armatures.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -15,11 +15,11 @@ def test_camera(clear_blend, camera_type):
|
|||||||
datablock.type = camera_type
|
datablock.type = camera_type
|
||||||
|
|
||||||
camera_dumper = BlCamera()
|
camera_dumper = BlCamera()
|
||||||
expected = camera_dumper._dump(datablock)
|
expected = camera_dumper.dump(datablock)
|
||||||
bpy.data.cameras.remove(datablock)
|
bpy.data.cameras.remove(datablock)
|
||||||
|
|
||||||
test = camera_dumper._construct(expected)
|
test = camera_dumper.construct(expected)
|
||||||
camera_dumper._load(expected, test)
|
camera_dumper.load(expected, test)
|
||||||
result = camera_dumper._dump(test)
|
result = camera_dumper.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -23,11 +23,11 @@ def test_collection(clear_blend):
|
|||||||
|
|
||||||
# Test
|
# Test
|
||||||
implementation = BlCollection()
|
implementation = BlCollection()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.collections.remove(datablock)
|
bpy.data.collections.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -19,11 +19,11 @@ def test_curve(clear_blend, curve_type):
|
|||||||
datablock = bpy.data.curves[0]
|
datablock = bpy.data.curves[0]
|
||||||
|
|
||||||
implementation = BlCurve()
|
implementation = BlCurve()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.curves.remove(datablock)
|
bpy.data.curves.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -13,11 +13,11 @@ def test_gpencil(clear_blend):
|
|||||||
datablock = bpy.data.grease_pencils[0]
|
datablock = bpy.data.grease_pencils[0]
|
||||||
|
|
||||||
implementation = BlGpencil()
|
implementation = BlGpencil()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.grease_pencils.remove(datablock)
|
bpy.data.grease_pencils.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -13,11 +13,11 @@ def test_lattice(clear_blend):
|
|||||||
datablock = bpy.data.lattices[0]
|
datablock = bpy.data.lattices[0]
|
||||||
|
|
||||||
implementation = BlLattice()
|
implementation = BlLattice()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.lattices.remove(datablock)
|
bpy.data.lattices.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -14,11 +14,11 @@ def test_lightprobes(clear_blend, lightprobe_type):
|
|||||||
|
|
||||||
blender_light = bpy.data.lightprobes[0]
|
blender_light = bpy.data.lightprobes[0]
|
||||||
lightprobe_dumper = BlLightprobe()
|
lightprobe_dumper = BlLightprobe()
|
||||||
expected = lightprobe_dumper._dump(blender_light)
|
expected = lightprobe_dumper.dump(blender_light)
|
||||||
bpy.data.lightprobes.remove(blender_light)
|
bpy.data.lightprobes.remove(blender_light)
|
||||||
|
|
||||||
test = lightprobe_dumper._construct(expected)
|
test = lightprobe_dumper.construct(expected)
|
||||||
lightprobe_dumper._load(expected, test)
|
lightprobe_dumper.load(expected, test)
|
||||||
result = lightprobe_dumper._dump(test)
|
result = lightprobe_dumper.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -13,11 +13,11 @@ def test_light(clear_blend, light_type):
|
|||||||
|
|
||||||
blender_light = bpy.data.lights[0]
|
blender_light = bpy.data.lights[0]
|
||||||
light_dumper = BlLight()
|
light_dumper = BlLight()
|
||||||
expected = light_dumper._dump(blender_light)
|
expected = light_dumper.dump(blender_light)
|
||||||
bpy.data.lights.remove(blender_light)
|
bpy.data.lights.remove(blender_light)
|
||||||
|
|
||||||
test = light_dumper._construct(expected)
|
test = light_dumper.construct(expected)
|
||||||
light_dumper._load(expected, test)
|
light_dumper.load(expected, test)
|
||||||
result = light_dumper._dump(test)
|
result = light_dumper.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -17,12 +17,12 @@ def test_material_nodes(clear_blend):
|
|||||||
datablock.node_tree.nodes.new(ntype)
|
datablock.node_tree.nodes.new(ntype)
|
||||||
|
|
||||||
implementation = BlMaterial()
|
implementation = BlMaterial()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.materials.remove(datablock)
|
bpy.data.materials.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
|
||||||
@ -32,11 +32,11 @@ def test_material_gpencil(clear_blend):
|
|||||||
bpy.data.materials.create_gpencil_data(datablock)
|
bpy.data.materials.create_gpencil_data(datablock)
|
||||||
|
|
||||||
implementation = BlMaterial()
|
implementation = BlMaterial()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.materials.remove(datablock)
|
bpy.data.materials.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -18,11 +18,11 @@ def test_mesh(clear_blend, mesh_type):
|
|||||||
|
|
||||||
# Test
|
# Test
|
||||||
implementation = BlMesh()
|
implementation = BlMesh()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.meshes.remove(datablock)
|
bpy.data.meshes.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -13,11 +13,11 @@ def test_metaball(clear_blend, metaballs_type):
|
|||||||
|
|
||||||
datablock = bpy.data.metaballs[0]
|
datablock = bpy.data.metaballs[0]
|
||||||
dumper = BlMetaball()
|
dumper = BlMetaball()
|
||||||
expected = dumper._dump(datablock)
|
expected = dumper.dump(datablock)
|
||||||
bpy.data.metaballs.remove(datablock)
|
bpy.data.metaballs.remove(datablock)
|
||||||
|
|
||||||
test = dumper._construct(expected)
|
test = dumper.construct(expected)
|
||||||
dumper._load(expected, test)
|
dumper.load(expected, test)
|
||||||
result = dumper._dump(test)
|
result = dumper.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -65,11 +65,11 @@ def test_object(clear_blend):
|
|||||||
datablock.shape_key_add(name='shape2')
|
datablock.shape_key_add(name='shape2')
|
||||||
|
|
||||||
implementation = BlObject()
|
implementation = BlObject()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.objects.remove(datablock)
|
bpy.data.objects.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
print(DeepDiff(expected, result))
|
print(DeepDiff(expected, result))
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -15,11 +15,11 @@ def test_scene(clear_blend):
|
|||||||
datablock.view_settings.use_curve_mapping = True
|
datablock.view_settings.use_curve_mapping = True
|
||||||
# Test
|
# Test
|
||||||
implementation = BlScene()
|
implementation = BlScene()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.scenes.remove(datablock)
|
bpy.data.scenes.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -12,11 +12,11 @@ def test_speaker(clear_blend):
|
|||||||
datablock = bpy.data.speakers[0]
|
datablock = bpy.data.speakers[0]
|
||||||
|
|
||||||
implementation = BlSpeaker()
|
implementation = BlSpeaker()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.speakers.remove(datablock)
|
bpy.data.speakers.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -14,11 +14,11 @@ def test_texture(clear_blend, texture_type):
|
|||||||
datablock = bpy.data.textures.new('test', texture_type)
|
datablock = bpy.data.textures.new('test', texture_type)
|
||||||
|
|
||||||
implementation = BlTexture()
|
implementation = BlTexture()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.textures.remove(datablock)
|
bpy.data.textures.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -11,11 +11,11 @@ def test_volume(clear_blend):
|
|||||||
datablock = bpy.data.volumes.new("Test")
|
datablock = bpy.data.volumes.new("Test")
|
||||||
|
|
||||||
implementation = BlVolume()
|
implementation = BlVolume()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.volumes.remove(datablock)
|
bpy.data.volumes.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
@ -12,11 +12,11 @@ def test_world(clear_blend):
|
|||||||
datablock.use_nodes = True
|
datablock.use_nodes = True
|
||||||
|
|
||||||
implementation = BlWorld()
|
implementation = BlWorld()
|
||||||
expected = implementation._dump(datablock)
|
expected = implementation.dump(datablock)
|
||||||
bpy.data.worlds.remove(datablock)
|
bpy.data.worlds.remove(datablock)
|
||||||
|
|
||||||
test = implementation._construct(expected)
|
test = implementation.construct(expected)
|
||||||
implementation._load(expected, test)
|
implementation.load(expected, test)
|
||||||
result = implementation._dump(test)
|
result = implementation.dump(test)
|
||||||
|
|
||||||
assert not DeepDiff(expected, result)
|
assert not DeepDiff(expected, result)
|
||||||
|
Reference in New Issue
Block a user