Exemplo n.º 1
0
    def test_gather_layer_names(self):
        # GIVEN
        layer_manager = LayerManager(bpy.context)
        obj_data = bpy.data.meshes.new("test_gather_layer_names_mesh")
        obj = bpy.data.objects.new(name="test_gather_layer_names", object_data=obj_data)

        # WHEN
        names = layer_manager.gather_layer_names(obj)

        # THEN
        self.assertEqual(len(names), 0)

        # WHEN
        layer_manager.add(["layer1"], obj)
        names = layer_manager.gather_layer_names(obj)

        # THEN
        self.assertEqual(len(names), 1)
        self.assertIn("layer1", names)

        # WHEN
        layer_manager.add(["layer2"], obj)
        names = layer_manager.gather_layer_names(obj)

        # THEN
        self.assertEqual(len(names), 2)
        self.assertIn("layer1", names)
        self.assertIn("layer2", names)
Exemplo n.º 2
0
    def test_add_layer(self):
        # GIVEN
        layer_manager = LayerManager(bpy.context)
        obj_data = bpy.data.meshes.new("test_add_layer_mesh")
        obj = bpy.data.objects.new(name="test_add_layer", object_data=obj_data)
        bpy.context.scene.objects.link(obj)
        obj.select = False

        # WHEN
        layer_manager.add(["layer_add"])

        # THEN
        self.assertEqual(len(layer_manager.gather_layer_names(obj)), 0)

        # WHEN
        obj.select = True
        layer_manager.add(["layer_add"])

        # THEN
        self.assertEqual(len(obj.kuesa.layers), 1)
        self.assertEqual(obj.kuesa.layers[0].name, "layer_add")

        # WHEN
        layer_manager.add(["layer_add"])

        # THEN
        self.assertEqual(len(obj.kuesa.layers), 1)