mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2026-01-07 03:41:20 +01:00
Merge branch 'rf/caster' of https://github.com/Beefy-Swain/pytiled_parser into rf/caster
This commit is contained in:
14
tests/test_data/tilesets/tileset_image.json
Normal file
14
tests/test_data/tilesets/tileset_image.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{ "columns":8,
|
||||||
|
"image":"..\/images\/tmw_desert_spacing.png",
|
||||||
|
"imageheight":199,
|
||||||
|
"imagewidth":265,
|
||||||
|
"margin":1,
|
||||||
|
"name":"tile_set_image",
|
||||||
|
"spacing":1,
|
||||||
|
"tilecount":48,
|
||||||
|
"tiledversion":"1.3.1",
|
||||||
|
"tileheight":32,
|
||||||
|
"tilewidth":32,
|
||||||
|
"type":"tileset",
|
||||||
|
"version":1.2
|
||||||
|
}
|
||||||
192
tests/test_data/tilesets/tileset_image_objects.json
Normal file
192
tests/test_data/tilesets/tileset_image_objects.json
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
{ "columns":8,
|
||||||
|
"image":"..\/images\/tmw_desert_spacing.png",
|
||||||
|
"imageheight":199,
|
||||||
|
"imagewidth":265,
|
||||||
|
"margin":1,
|
||||||
|
"name":"tile_set_image",
|
||||||
|
"spacing":1,
|
||||||
|
"tilecount":5,
|
||||||
|
"tiledversion":"1.3.1",
|
||||||
|
"tileheight":32,
|
||||||
|
"tiles":[
|
||||||
|
{
|
||||||
|
"id":9,
|
||||||
|
"objectgroup":
|
||||||
|
{
|
||||||
|
"draworder":"index",
|
||||||
|
"name":"",
|
||||||
|
"objects":[
|
||||||
|
{
|
||||||
|
"height":32,
|
||||||
|
"id":2,
|
||||||
|
"name":"wall",
|
||||||
|
"rotation":1,
|
||||||
|
"type":"rectangle type",
|
||||||
|
"visible":true,
|
||||||
|
"width":32,
|
||||||
|
"x":1,
|
||||||
|
"y":1
|
||||||
|
}],
|
||||||
|
"opacity":1,
|
||||||
|
"type":"objectgroup",
|
||||||
|
"visible":true,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":19,
|
||||||
|
"objectgroup":
|
||||||
|
{
|
||||||
|
"draworder":"index",
|
||||||
|
"name":"",
|
||||||
|
"objects":[
|
||||||
|
{
|
||||||
|
"height":0,
|
||||||
|
"id":1,
|
||||||
|
"name":"wall corner",
|
||||||
|
"polygon":[
|
||||||
|
{
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x":-32,
|
||||||
|
"y":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x":-32,
|
||||||
|
"y":32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x":-16,
|
||||||
|
"y":32.1818
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x":-15.8182,
|
||||||
|
"y":16.9091
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x":0.181818,
|
||||||
|
"y":17.0909
|
||||||
|
}],
|
||||||
|
"rotation":1,
|
||||||
|
"type":"polygon type",
|
||||||
|
"visible":true,
|
||||||
|
"width":0,
|
||||||
|
"x":32,
|
||||||
|
"y":1
|
||||||
|
}],
|
||||||
|
"opacity":1,
|
||||||
|
"type":"objectgroup",
|
||||||
|
"visible":true,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":20,
|
||||||
|
"objectgroup":
|
||||||
|
{
|
||||||
|
"draworder":"index",
|
||||||
|
"name":"",
|
||||||
|
"objects":[
|
||||||
|
{
|
||||||
|
"height":0,
|
||||||
|
"id":1,
|
||||||
|
"name":"polyline",
|
||||||
|
"polyline":[
|
||||||
|
{
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x":25.0909,
|
||||||
|
"y":21.2727
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x":9.63636,
|
||||||
|
"y":28.3636
|
||||||
|
}],
|
||||||
|
"rotation":1,
|
||||||
|
"type":"polyline type",
|
||||||
|
"visible":true,
|
||||||
|
"width":0,
|
||||||
|
"x":1.45455,
|
||||||
|
"y":1.45455
|
||||||
|
}],
|
||||||
|
"opacity":1,
|
||||||
|
"type":"objectgroup",
|
||||||
|
"visible":true,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":31,
|
||||||
|
"objectgroup":
|
||||||
|
{
|
||||||
|
"draworder":"index",
|
||||||
|
"name":"",
|
||||||
|
"objects":[
|
||||||
|
{
|
||||||
|
"ellipse":true,
|
||||||
|
"height":19.2727,
|
||||||
|
"id":1,
|
||||||
|
"name":"rock 1",
|
||||||
|
"rotation":1,
|
||||||
|
"type":"elipse type",
|
||||||
|
"visible":true,
|
||||||
|
"width":19.6364,
|
||||||
|
"x":5.09091,
|
||||||
|
"y":2.54545
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ellipse":true,
|
||||||
|
"height":8.36364,
|
||||||
|
"id":2,
|
||||||
|
"name":"rock 2",
|
||||||
|
"rotation":-1,
|
||||||
|
"type":"elipse type",
|
||||||
|
"visible":true,
|
||||||
|
"width":8.54545,
|
||||||
|
"x":16.1818,
|
||||||
|
"y":22
|
||||||
|
}],
|
||||||
|
"opacity":1,
|
||||||
|
"type":"objectgroup",
|
||||||
|
"visible":true,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":45,
|
||||||
|
"objectgroup":
|
||||||
|
{
|
||||||
|
"draworder":"index",
|
||||||
|
"name":"",
|
||||||
|
"objects":[
|
||||||
|
{
|
||||||
|
"height":0,
|
||||||
|
"id":1,
|
||||||
|
"name":"sign",
|
||||||
|
"point":true,
|
||||||
|
"rotation":0,
|
||||||
|
"type":"point type",
|
||||||
|
"visible":true,
|
||||||
|
"width":0,
|
||||||
|
"x":14.7273,
|
||||||
|
"y":26.3636
|
||||||
|
}],
|
||||||
|
"opacity":1,
|
||||||
|
"type":"objectgroup",
|
||||||
|
"visible":true,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
"tilewidth":32,
|
||||||
|
"type":"tileset",
|
||||||
|
"version":1.2
|
||||||
|
}
|
||||||
23
tests/test_tileset.py
Normal file
23
tests/test_tileset.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
"""Tests for tilesets"""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from pytiled_parser import tileset
|
||||||
|
|
||||||
|
TESTS_DIR = Path(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
TEST_DATA = TESTS_DIR / "test_data"
|
||||||
|
TILE_SETS = TEST_DATA / "tilesets"
|
||||||
|
|
||||||
|
|
||||||
|
ALL_TILESETS = TILE_SETS.glob("*.json")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("raw_tileset", ALL_TILESETS)
|
||||||
|
def test_tilesets_integration(raw_tileset):
|
||||||
|
""" This could be redundant, but it is useful just to ensure that anything in there
|
||||||
|
is at least sanity checked"""
|
||||||
|
tileset_ = tileset.cast(json.loads(raw_tileset))
|
||||||
|
assert tileset_ is not None
|
||||||
Reference in New Issue
Block a user