<commit_before>"""Export and import textured meshes."""

import bpy
import nose.tools
import os

import io_scene_nif.export_nif
from pyffi.formats.nif import NifFormat
from test.test_cube import TestCube

class TestBaseUVTexture(TestCube):
    n_name = "base_uv_texture"

    def b_create_object(self):
        b_obj = TestCube.b_create_object(self)
        b_mat = bpy.data.materials.new(name='Material')
        b_mtex = b_mat.texture_slots.create(0)
        b_mtex.texture_coords = 'UV'
        b_mtex.use_map_color_diffuse = True
        b_mtex.texture = bpy.data.textures.new(name='Tex', type='IMAGE')
        b_mtex.texture.image = bpy.data.images.new('textures' + os.sep + 'image.dds', 1, 1)
        b_obj.data.materials.append(b_mat)
        bpy.ops.object.editmode_toggle()
        bpy.ops.uv.cube_project() # named 'UVTex'
        bpy.ops.object.editmode_toggle()
        b_mtex.uv_layer = 'UVTex'
        return b_obj

    def b_check_object(self, b_obj):
        b_mesh = b_obj.data
        nose.tools.assert_equal(len(b_mesh.materials), 1)
        b_mat = b_mesh.materials[0]
        b_mtex = b_mat.texture_slots[0]
        nose.tools.assert_equal(b_mtex.use, True)
        nose.tools.assert_equal(b_mtex.texture_coords, 'UV')
        nose.tools.assert_equal(b_mtex.use_map_color_diffuse, True)
        nose.tools.assert_is_instance(b_mtex.texture, bpy.types.ImageTexture)
        nose.tools.assert_equal(
            b_mtex.texture.image.filepath, 'textures' + os.sep + 'image.dds')

    def n_check_data(self, n_data):
        n_geom = n_data.roots[0].children[0]
        nose.tools.assert_equal(len(n_geom.data.uv_sets), 1)
        nose.tools.assert_equal(
            len(n_geom.data.uv_sets[0]), len(n_geom.data.vertices))
        nose.tools.assert_equal(n_geom.num_properties, 2)
        self.n_check_texturing_property(n_geom.properties[0])<commit_msg>In uv texture test, disable specular property export.<commit_after>"""Export and import textured meshes."""

import bpy
import nose.tools
import os

import io_scene_nif.export_nif
from pyffi.formats.nif import NifFormat
from test.test_cube import TestCube

class TestBaseUVTexture(TestCube):
    n_name = "base_uv_texture"

    def b_create_object(self):
        b_obj = TestCube.b_create_object(self)
        b_mat = bpy.data.materials.new(name='Material')
        b_mat.specular_intensity = 0 # disable NiSpecularProperty
        b_mtex = b_mat.texture_slots.create(0)
        b_mtex.texture_coords = 'UV'
        b_mtex.use_map_color_diffuse = True
        b_mtex.texture = bpy.data.textures.new(name='Tex', type='IMAGE')
        b_mtex.texture.image = bpy.data.images.new('textures' + os.sep + 'image.dds', 1, 1)
        b_obj.data.materials.append(b_mat)
        bpy.ops.object.editmode_toggle()
        bpy.ops.uv.cube_project() # named 'UVTex'
        bpy.ops.object.editmode_toggle()
        b_mtex.uv_layer = 'UVTex'
        return b_obj

    def b_check_object(self, b_obj):
        b_mesh = b_obj.data
        nose.tools.assert_equal(len(b_mesh.materials), 1)
        b_mat = b_mesh.materials[0]
        b_mtex = b_mat.texture_slots[0]
        nose.tools.assert_equal(b_mtex.use, True)
        nose.tools.assert_equal(b_mtex.texture_coords, 'UV')
        nose.tools.assert_equal(b_mtex.use_map_color_diffuse, True)
        nose.tools.assert_is_instance(b_mtex.texture, bpy.types.ImageTexture)
        nose.tools.assert_equal(
            b_mtex.texture.image.filepath, 'textures' + os.sep + 'image.dds')

    def n_check_data(self, n_data):
        n_geom = n_data.roots[0].children[0]
        nose.tools.assert_equal(len(n_geom.data.uv_sets), 1)
        nose.tools.assert_equal(
            len(n_geom.data.uv_sets[0]), len(n_geom.data.vertices))
        nose.tools.assert_equal(n_geom.num_properties, 2)
        self.n_check_texturing_property(n_geom.properties[0])
{'fraction_non_alphanumeric': 0.11558441558441558, 'fraction_numerical': 0.006493506493506494, 'mean_word_length': 3.1319742489270386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4186738', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1425, 'n_words': 196}