Skip to content

Commit

Permalink
Merge pull request #532 from Moo-Ack-Productions/mcprep-3_5_2-patch
Browse files Browse the repository at this point in the history
Fixed incorrect keyword argument
  • Loading branch information
TheDuckCow authored Jan 9, 2024
2 parents 5aaee32 + 29df266 commit f3c5c7b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
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)

0 comments on commit f3c5c7b

Please sign in to comment.