47 lines
1.0 KiB
Python
47 lines
1.0 KiB
Python
from io import StringIO
|
|
from textwrap import dedent
|
|
|
|
import pytest
|
|
|
|
from tilemapper import battlemap, tileset
|
|
|
|
|
|
@pytest.fixture
|
|
def manager():
|
|
return tileset.TileSetManager()
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_map():
|
|
return dedent(
|
|
"""
|
|
........ 1
|
|
........ ........ 2
|
|
........ ........
|
|
.......L...D... D
|
|
........ .... ...
|
|
........ ...d ...
|
|
.
|
|
.........S. 3
|
|
5 . .
|
|
....S... ...d.... 4
|
|
........ ........
|
|
........ ........
|
|
|
|
"""
|
|
)
|
|
|
|
|
|
def test_tileset_loader(manager):
|
|
assert "colorized" in manager.available
|
|
assert "ascii" in manager.available
|
|
|
|
|
|
def test_renderer(manager, sample_map):
|
|
test_map = battlemap.BattleMap("test map", source=StringIO(sample_map), tileset=manager.load("ascii"))
|
|
test_map.load()
|
|
assert test_map.width == 21
|
|
assert test_map.height == 12
|
|
assert test_map.source_data == sample_map.strip("\n")
|
|
assert str(test_map) == sample_map.strip("\n")
|