mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2025-12-31 08:33:47 +01:00
yay
This commit is contained in:
18
tests/unit2/test_parser.py
Normal file
18
tests/unit2/test_parser.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import pytest
|
||||
|
||||
import xml.etree.ElementTree as etree
|
||||
|
||||
from typing import Callable
|
||||
|
||||
from pytiled_parser import xml_parser
|
||||
|
||||
|
||||
def _get_root_element(xml: str) -> Callable:
|
||||
pass
|
||||
|
||||
|
||||
layer_data = []
|
||||
|
||||
|
||||
def test_parse_layer(element, expected):
|
||||
pass
|
||||
@@ -16,7 +16,8 @@ def test_map_simple():
|
||||
TMX with a very simple spritesheet tile set and some properties.
|
||||
"""
|
||||
map = pytiled_parser.parse_tile_map(
|
||||
Path("../test_data/test_map_simple.tmx"))
|
||||
Path("../test_data/test_map_simple.tmx")
|
||||
)
|
||||
|
||||
# map
|
||||
# unsure how to get paths to compare propperly
|
||||
@@ -38,13 +39,13 @@ def test_map_simple():
|
||||
assert map.background_color == None
|
||||
|
||||
assert map.properties == {
|
||||
"bool property - false": False,
|
||||
"bool property - true": True,
|
||||
"color property": (0x49, 0xfc, 0xff, 0xff),
|
||||
"file property": Path("/var/log/syslog"),
|
||||
"float property": 1.23456789,
|
||||
"int property": 13,
|
||||
"string property": "Hello, World!!"
|
||||
"bool property - false": False,
|
||||
"bool property - true": True,
|
||||
"color property": (0x49, 0xFC, 0xFF, 0xFF),
|
||||
"file property": Path("/var/log/syslog"),
|
||||
"float property": 1.23456789,
|
||||
"int property": 13,
|
||||
"string property": "Hello, World!!",
|
||||
}
|
||||
|
||||
# tileset
|
||||
@@ -60,7 +61,8 @@ def test_map_simple():
|
||||
|
||||
# unsure how to get paths to compare propperly
|
||||
assert str(map.tile_sets[1].image.source) == (
|
||||
"images/tmw_desert_spacing.png")
|
||||
"images/tmw_desert_spacing.png"
|
||||
)
|
||||
assert map.tile_sets[1].image.trans == None
|
||||
assert map.tile_sets[1].image.size == (265, 199)
|
||||
|
||||
@@ -68,28 +70,31 @@ def test_map_simple():
|
||||
assert map.tile_sets[1].tiles == {}
|
||||
|
||||
# layers
|
||||
assert map.layers[0].data == [[1,2,3,4,5,6,7,8],
|
||||
[9,10,11,12,13,14,15,16],
|
||||
[17,18,19,20,21,22,23,24],
|
||||
[25,26,27,28,29,30,31,32],
|
||||
[33,34,35,36,37,38,39,40],
|
||||
[41,42,43,44,45,46,47,48]]
|
||||
assert map.layers[0].data == [
|
||||
[1, 2, 3, 4, 5, 6, 7, 8],
|
||||
[9, 10, 11, 12, 13, 14, 15, 16],
|
||||
[17, 18, 19, 20, 21, 22, 23, 24],
|
||||
[25, 26, 27, 28, 29, 30, 31, 32],
|
||||
[33, 34, 35, 36, 37, 38, 39, 40],
|
||||
[41, 42, 43, 44, 45, 46, 47, 48],
|
||||
]
|
||||
assert map.layers[0].id == 1
|
||||
assert map.layers[0].name == "Tile Layer 1"
|
||||
assert map.layers[0].offset == (0, 0)
|
||||
assert map.layers[0].opacity == 0xFF
|
||||
assert map.layers[0].offset == None
|
||||
assert map.layers[0].opacity == None
|
||||
assert map.layers[0].properties == None
|
||||
assert map.layers[0].size == (8, 6)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected", [
|
||||
("#001122", (0x00, 0x11, 0x22, 0xff)),
|
||||
("001122", (0x00, 0x11, 0x22, 0xff)),
|
||||
("#FF001122", (0x00, 0x11, 0x22, 0xff)),
|
||||
("FF001122", (0x00, 0x11, 0x22, 0xff)),
|
||||
("FF001122", (0x00, 0x11, 0x22, 0xff)),
|
||||
]
|
||||
"test_input,expected",
|
||||
[
|
||||
("#001122", (0x00, 0x11, 0x22, 0xFF)),
|
||||
("001122", (0x00, 0x11, 0x22, 0xFF)),
|
||||
("#FF001122", (0x00, 0x11, 0x22, 0xFF)),
|
||||
("FF001122", (0x00, 0x11, 0x22, 0xFF)),
|
||||
("FF001122", (0x00, 0x11, 0x22, 0xFF)),
|
||||
],
|
||||
)
|
||||
def test_color_parsing(test_input, expected):
|
||||
"""
|
||||
Reference in New Issue
Block a user