51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
from scripts.reimport_textures import reimport_textures
|
|
|
|
|
|
def test_copies_files_preserving_relative_paths(tmp_path):
|
|
src = tmp_path / "art_wip"
|
|
dest = tmp_path / "resources_textures"
|
|
(src / "tiles").mkdir(parents=True)
|
|
(src / "tiles" / "grass.png").write_bytes(b"fake-png-bytes")
|
|
|
|
count = reimport_textures(src, dest)
|
|
|
|
assert count == 1
|
|
assert (dest / "tiles" / "grass.png").read_bytes() == b"fake-png-bytes"
|
|
|
|
|
|
def test_overwrites_an_existing_destination_file(tmp_path):
|
|
src = tmp_path / "art_wip"
|
|
dest = tmp_path / "resources_textures"
|
|
(src / "items").mkdir(parents=True)
|
|
(src / "items" / "staff_oak.png").write_bytes(b"new-art")
|
|
(dest / "items").mkdir(parents=True)
|
|
(dest / "items" / "staff_oak.png").write_bytes(b"old-placeholder")
|
|
|
|
reimport_textures(src, dest)
|
|
|
|
assert (dest / "items" / "staff_oak.png").read_bytes() == b"new-art"
|
|
|
|
|
|
def test_copies_multiple_nested_files(tmp_path):
|
|
src = tmp_path / "art_wip"
|
|
dest = tmp_path / "resources_textures"
|
|
(src / "a" / "b").mkdir(parents=True)
|
|
(src / "a" / "b" / "one.png").write_bytes(b"1")
|
|
(src / "a" / "two.png").write_bytes(b"2")
|
|
|
|
count = reimport_textures(src, dest)
|
|
|
|
assert count == 2
|
|
assert (dest / "a" / "b" / "one.png").read_bytes() == b"1"
|
|
assert (dest / "a" / "two.png").read_bytes() == b"2"
|
|
|
|
|
|
def test_ignores_directories_themselves(tmp_path):
|
|
src = tmp_path / "art_wip"
|
|
dest = tmp_path / "resources_textures"
|
|
(src / "empty_dir").mkdir(parents=True)
|
|
|
|
count = reimport_textures(src, dest)
|
|
|
|
assert count == 0
|