Mi2dRPGamEng/tests/test_ui_assets.py

25 lines
947 B
Python

from engine.render.ui_draw import glyph_texture_path, panel_texture_path
from engine.ui_assets import UI_PANEL_COLORS, generate_ui_textures
def test_generate_ui_textures_writes_a_glyph_and_panel_file(tmp_path):
generate_ui_textures(tmp_path)
assert (tmp_path / glyph_texture_path("A")).exists()
assert (tmp_path / panel_texture_path("background")).exists()
def test_generate_ui_textures_writes_every_declared_panel_color(tmp_path):
generate_ui_textures(tmp_path)
for name in UI_PANEL_COLORS:
assert (tmp_path / panel_texture_path(name)).exists()
def test_generate_ui_textures_does_not_overwrite_existing_files(tmp_path):
generate_ui_textures(tmp_path)
path = tmp_path / glyph_texture_path("A")
original_bytes = path.read_bytes()
path.write_bytes(b"not-a-real-png")
generate_ui_textures(tmp_path)
assert path.read_bytes() == b"not-a-real-png"
assert path.read_bytes() != original_bytes