Ejemplo n.º 1
0
def test_vanilla_zip(minecraft_resource_pack: Path, tmp_path: Path):
    pack = ResourcePack(path=minecraft_resource_pack)
    zipped_pack = pack.save(tmp_path, zipped=True)
    assert ResourcePack(path=zipped_pack) == ResourcePack(path=zipped_pack)
Ejemplo n.º 2
0
import pytest
from PIL import Image, ImageDraw

from beet import JsonFile, PngFile, ResourcePack, Texture


def test_default():
    assert ResourcePack() == ResourcePack()
    assert not ResourcePack()


@pytest.mark.parametrize(  # type: ignore
    "pack",
    [
        ResourcePack("p1"),
        ResourcePack("p2", mcmeta=JsonFile({"pack": {"description": "world"}})),
        ResourcePack(
            "p3", mcmeta=JsonFile({"pack": {"description": "world", "pack_format": 42}})
        ),
    ],
)
def test_empty(snapshot: Any, pack: ResourcePack):
    assert snapshot("resource_pack") == pack
    assert not pack
    assert dict(pack) == {}


def test_empty_with_image():
    pack = ResourcePack(image=PngFile(Image.new("RGB", (32, 32), color="blue")))
    assert pack
Ejemplo n.º 3
0
def test_vanilla_compare(minecraft_resource_pack: Path):
    assert ResourcePack(path=minecraft_resource_pack) == ResourcePack(
        path=minecraft_resource_pack
    )
Ejemplo n.º 4
0
def test_resource_pack():
    pack = ResourcePack()
    doc = Document(assets=pack)
    assert doc.assets is pack
Ejemplo n.º 5
0
 def load(self, path: Path) -> ResourcePack:
     return ResourcePack(path=next(path.iterdir()))
Ejemplo n.º 6
0
 def load(self, path: Path) -> ResourcePack:
     return ignore_name(ResourcePack(path=path))
Ejemplo n.º 7
0
def test_default():
    assert ResourcePack() == ResourcePack()
    assert not ResourcePack()
Ejemplo n.º 8
0
def test_empty_namespaces():
    pack = ResourcePack()

    assert not pack
    assert not pack["hello"]
    assert not pack["world"]
Ejemplo n.º 9
0
def test_vanilla_particles(snapshot: SnapshotFixture, minecraft_resource_pack: Path):
    pack = ResourcePack(path=minecraft_resource_pack)
    assert snapshot("json") == pack.particles["minecraft:end_rod"].data
Ejemplo n.º 10
0
def test_vanilla_shaders(snapshot: SnapshotFixture, minecraft_resource_pack: Path):
    pack = ResourcePack(path=minecraft_resource_pack)
    assert snapshot("json") == pack.shader_posts["minecraft:spider"].data
    assert snapshot("json") == pack.shaders["minecraft:program/entity_outline"].data
    assert snapshot() == pack.fragment_shaders["minecraft:program/wobble"].text
    assert snapshot() == pack.vertex_shaders["minecraft:program/sobel"].text