From 21281361c082455721c7aa8e63ccbcf4e807dbd7 Mon Sep 17 00:00:00 2001 From: Benjamin Kirkbride Date: Sat, 30 May 2020 20:33:31 -0400 Subject: [PATCH 1/5] tests: width and height were reversed --- tests/test_tiled_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tiled_object.py b/tests/test_tiled_object.py index 22797f0..72d7c99 100644 --- a/tests/test_tiled_object.py +++ b/tests/test_tiled_object.py @@ -23,7 +23,7 @@ RECTANGLES = [ """, tiled_object.Rectangle( id_=1, - size=common_types.Size(41.4686825053996, 45.3972945322269), + size=common_types.Size(45.3972945322269, 41.4686825053996), name="name: rectangle", rotation=0, type="rectangle", From 93f603557adf996745663898d7901a9ea395a180 Mon Sep 17 00:00:00 2001 From: Benjamin Kirkbride Date: Sat, 30 May 2020 20:51:11 -0400 Subject: [PATCH 2/5] tests: Ben is fickle when it comes to json formatting --- tests/test_tiled_object.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_tiled_object.py b/tests/test_tiled_object.py index 72d7c99..d1b4e7f 100644 --- a/tests/test_tiled_object.py +++ b/tests/test_tiled_object.py @@ -11,7 +11,8 @@ ELLIPSES = [] RECTANGLES = [ ( """ - {"height":41.4686825053996, + { + "height":41.4686825053996, "id":1, "name":"name: rectangle", "rotation":0, @@ -19,7 +20,8 @@ RECTANGLES = [ "visible":true, "width":45.3972945322269, "x":27.7185404115039, - "y":23.571672160964} + "y":23.571672160964 + } """, tiled_object.Rectangle( id_=1, @@ -36,7 +38,8 @@ RECTANGLES = [ POINTS = [ ( """ - {"height":0, + { + "height":0, "id":2, "name":"name: point", "point":true, @@ -45,7 +48,8 @@ POINTS = [ "visible":true, "width":0, "x":159.981811981357, - "y":82.9373650107991} + "y":82.9373650107991 + } """, { "height": 0, From ef2002833849e2fa7a9262fe525079113283a673 Mon Sep 17 00:00:00 2001 From: Benjamin Kirkbride Date: Sat, 30 May 2020 21:36:20 -0400 Subject: [PATCH 3/5] tests: add rectangles to list --- tests/test_tiled_object.py | 138 ++++++++++++++++++++++++++++++++++++- 1 file changed, 137 insertions(+), 1 deletion(-) diff --git a/tests/test_tiled_object.py b/tests/test_tiled_object.py index d1b4e7f..2ca7806 100644 --- a/tests/test_tiled_object.py +++ b/tests/test_tiled_object.py @@ -1,10 +1,11 @@ """Tests for objects""" import xml.etree.ElementTree as etree from contextlib import ExitStack as does_not_raise +from pathlib import Path import pytest -from pytiled_parser import common_types, tiled_object +from pytiled_parser import common_types, properties, tiled_object ELLIPSES = [] @@ -33,6 +34,141 @@ RECTANGLES = [ coordinates=common_types.OrderedPair(27.7185404115039, 23.571672160964), ), ), + ( + """ + { + "height":32.7384335568944, + "id":4, + "name":"name: rectangle - invisible", + "rotation":0, + "type":"rectangle", + "visible":false, + "width":30.9923837671934, + "x":163.910424008185, + "y":91.0128452881664 + } + """, + tiled_object.Rectangle( + id_=4, + size=common_types.Size(30.9923837671934, 32.7384335568944), + name="name: rectangle - invisible", + rotation=0, + type="rectangle", + visible=False, + coordinates=common_types.OrderedPair(163.910424008185, 91.0128452881664), + ), + ), + ( + """ + { + "height":22, + "id":5, + "name":"name: rectangle - rotated", + "rotation":10, + "type":"rectangle", + "visible":true, + "width":10, + "x":183.335227918609, + "y":23.3534159372513 + }, + """, + tiled_object.Rectangle( + id_=5, + size=common_types.Size(10, 22), + name="name: rectangle - rotated", + rotation=10, + type="rectangle", + visible=True, + coordinates=common_types.OrderedPair(183.335227918609, 23.3534159372513), + ), + ), + ( + """ + { + "height":0, + "id":28, + "name":"name: rectangle - no width or height", + "rotation":0, + "type":"rectangle", + "visible":true, + "width":0, + "x":131.17199045129, + "y":53.4727748095942 + } + """, + tiled_object.Rectangle( + id_=28, + size=common_types.Size(0, 0), + name="name: rectangle - no width or height", + rotation=0, + type="rectangle", + visible=True, + coordinates=common_types.OrderedPair(131.17199045129, 53.4727748095942), + ), + ), + ( + r""" + { + "height":13.7501420938956, + "id":30, + "name":"name: rectangle - properties", + "properties":[ + { + "name":"bool property", + "type":"bool", + "value":false + }, + { + "name":"color property", + "type":"color", + "value":"#ffaa0000" + }, + { + "name":"file property", + "type":"file", + "value":"..\/..\/..\/..\/..\/..\/dev\/null" + }, + { + "name":"float property", + "type":"float", + "value":42.1 + }, + { + "name":"int property", + "type":"int", + "value":8675309 + }, + { + "name":"string property", + "type":"string", + "value":"pytiled_parser rulez!1!!" + }], + "rotation":0, + "type":"rectangle", + "visible":true, + "width":21.170853700125, + "x":39.0678640445606, + "y":131.826759122428 + } + """, + tiled_object.Rectangle( + id_=30, + size=common_types.Size(21.170853700125, 13.7501420938956), + name="name: rectangle - properties", + rotation=0, + type="rectangle", + visible=True, + coordinates=common_types.OrderedPair(39.0678640445606, 131.826759122428), + properties={ + "bool property": False, + "color property": "#ffaa0000", + "file property": Path("../../../../../../dev/null"), + "float property": 42.1, + "int property": 8675309, + "string property": "pytiled_parser rulez!1!!", + }, + ), + ), ] POINTS = [ From 2424e7304efdde47ec6cfd800c3260099796c5e8 Mon Sep 17 00:00:00 2001 From: Benjamin Kirkbride Date: Sat, 30 May 2020 21:40:04 -0400 Subject: [PATCH 4/5] tests: remove unused imports --- tests/test_tiled_object.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_tiled_object.py b/tests/test_tiled_object.py index ea8a989..f55a792 100644 --- a/tests/test_tiled_object.py +++ b/tests/test_tiled_object.py @@ -1,11 +1,10 @@ """Tests for objects""" -import xml.etree.ElementTree as etree from contextlib import ExitStack as does_not_raise from pathlib import Path import pytest -from pytiled_parser import common_types, properties, tiled_object +from pytiled_parser import common_types, tiled_object ELLIPSES = [ ( From 9e5453896de0b9bfd2dc3400634fc39146b61306 Mon Sep 17 00:00:00 2001 From: Benjamin Kirkbride Date: Sat, 30 May 2020 21:47:43 -0400 Subject: [PATCH 5/5] tests: remove whitespace --- tests/test_tiled_object.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_tiled_object.py b/tests/test_tiled_object.py index f55a792..64abf24 100644 --- a/tests/test_tiled_object.py +++ b/tests/test_tiled_object.py @@ -292,19 +292,19 @@ POLYLINES = [ { "x":0, "y":0 - }, + }, { "x":19.424803910424, "y":27.063771740366 - }, + }, { "x":19.6430601341366, "y":3.05558713197681 - }, + }, { "x":-2.61907468455156, "y":15.9327043310219 - }, + }, { "x":25.317721950665, "y":16.3692167784472 @@ -384,23 +384,23 @@ POLYLINES = [ { "x":0, "y":0 - }, + }, { "x":-12.8771171990451, "y":0 - }, + }, { "x":-6.98419915880413, "y":7.63896782994203 - }, + }, { "x":-13.9683983176083, "y":16.8057292258725 - }, + }, { "x":3.71035580311468, "y":15.277935659884 - }, + }, { "x":-3.71035580311471, "y":8.29373650107991 @@ -410,7 +410,7 @@ POLYLINES = [ "visible":true, "width":0, "x":152.779356598841, - "y":19.8613163578493 + "y":19.8613163578493 } """, tiled_object.Polyline( @@ -440,11 +440,11 @@ POLYLINES = [ { "x":0, "y":0 - }, + }, { "x":-13.3136296464704, "y":41.0321700579743 - }, + }, { "x":21.3891099238377, "y":16.8057292258725