Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect keyword argument #532

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MCprep_addon/materials/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def set_texture_pack(

image_data = util.loadTexture(image)
_ = set_cycles_texture(
image_data, material, use_extra_passes=use_extra_passes)
image_data, material, extra_passes=use_extra_passes)
return 1


Expand Down
43 changes: 43 additions & 0 deletions test_files/materials_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import bpy
from bpy.types import Material

from MCprep_addon import util
from MCprep_addon.materials import generate
from MCprep_addon.materials import sequences
from MCprep_addon.materials.generate import find_additional_passes
Expand Down Expand Up @@ -875,6 +876,48 @@ def test_replace_missing_images_animated(self):
self.assertEqual(node.image.source, "SEQUENCE",
"Ensure updated material is an image sequence")

def test_swap_texture_pack(self):
"""End to end test of swap texture pack."""
self._set_test_mcprep_texturepack_path()
new_mat, _ = self._create_canon_mat("diamond_ore", test_pack=True)

bpy.ops.mesh.primitive_plane_add()
obj = bpy.context.object
obj.active_material = new_mat
self.assertIsNotNone(obj.active_material, "Material should be applied")

# Ensure if no texture pack selected, it fails.
addon_prefs = util.get_user_preferences(bpy.context)
addon_prefs.MCprep_exporter_type = "(choose)"
with self.assertRaises(RuntimeError):
res = bpy.ops.mcprep.swap_texture_pack(
filepath=bpy.context.scene.mcprep_texturepack_path)

# Now run in scenario where a valid selection is made.
with self.subTest("jmc2obj_noprep"):
addon_prefs.MCprep_exporter_type = "jmc2obj"
res = bpy.ops.mcprep.swap_texture_pack(
filepath=bpy.context.scene.mcprep_texturepack_path,
prepMaterials=False)
self.assertTrue(res, {"FINISHED"})

# And again with prep materials on
with self.subTest("jmc2obj_withprep"):
res = bpy.ops.mcprep.swap_texture_pack(
filepath=bpy.context.scene.mcprep_texturepack_path,
prepMaterials=True)
self.assertTrue(res, {"FINISHED"})

# And for good coverage, let's do an example for mineways
with self.subTest("Mineways_withprep"):
new_mat, _ = self._create_canon_mat("diamond_ore", test_pack=True)
obj.active_material = new_mat
addon_prefs.MCprep_exporter_type = "Mineways"
res = bpy.ops.mcprep.swap_texture_pack(
filepath=bpy.context.scene.mcprep_texturepack_path,
prepMaterials=True)
self.assertTrue(res, {"FINISHED"})


if __name__ == '__main__':
unittest.main(exit=False)