Skip to content

Commit 03a7354

Browse files
committed
iwyu
1 parent 07884e8 commit 03a7354

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
3+
from postgis import Point, LineString, Polygon, GeometryCollection
4+
5+
pytestmark = pytest.mark.asyncio
6+
7+
8+
POLYGON = Polygon((
9+
((1, 2), (3, 4), (5, 6), (1, 2)),
10+
((2, 3), (4, 5), (6, 7), (2, 3))
11+
))
12+
13+
COLLECTION = [
14+
Point(1, 2),
15+
LineString(((1, 2), (3, 4))),
16+
POLYGON
17+
]
18+
19+
20+
async def test_geometrycollection_should_round(connection):
21+
geom = GeometryCollection(COLLECTION, srid=4326)
22+
await connection.execute('INSERT INTO geometrycollection_async (geom) '
23+
'VALUES ($1)', geom)
24+
geom = await connection.fetchval('SELECT geom '
25+
'FROM geometrycollection_async '
26+
'WHERE geom=$1', geom, column=0)
27+
assert geom == COLLECTION

tests/asyncpg/test_linestring.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
from postgis import LineString
4+
5+
pytestmark = pytest.mark.asyncio
6+
7+
8+
@pytest.mark.parametrize('expected', [
9+
((30, 10), (10, 30), (40, 40)),
10+
])
11+
async def test_linestring_should_round(connection, expected):
12+
geom = LineString(expected, srid=4326)
13+
await connection.execute('INSERT INTO linestring_async (geom) VALUES ($1)',
14+
geom)
15+
geom = await connection.fetchval('SELECT geom FROM linestring_async WHERE '
16+
'geom=$1', geom, column=0)
17+
assert geom.coords == expected

tests/asyncpg/test_multilinestring.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
from postgis import MultiLineString
4+
5+
pytestmark = pytest.mark.asyncio
6+
7+
8+
@pytest.mark.parametrize('expected', [
9+
(((30, 10), (10, 30)), ((40, 10), (10, 40))),
10+
])
11+
async def test_multilinestring_should_round(connection, expected):
12+
geom = MultiLineString(expected, srid=4326)
13+
await connection.execute('INSERT INTO multilinestring_async (geom) '
14+
'VALUES ($1)', geom)
15+
geom = await connection.fetchval('SELECT geom FROM multilinestring_async '
16+
'WHERE geom=$1', geom, column=0)
17+
assert geom.coords == expected

tests/asyncpg/test_multipolygon.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pytest
2+
3+
from postgis import MultiPolygon
4+
5+
pytestmark = pytest.mark.asyncio
6+
7+
MULTI = (
8+
(
9+
((35, 10), (45, 45), (15, 40), (10, 20), (35, 10)),
10+
((20, 30), (35, 35), (30, 20), (20, 30))
11+
),
12+
(
13+
((36, 10), (46, 45), (16, 40), (16, 20), (36, 10)),
14+
((21, 30), (36, 35), (36, 20), (21, 30))
15+
),
16+
)
17+
18+
19+
@pytest.mark.parametrize('expected', [
20+
MULTI,
21+
])
22+
async def test_multipolygon_should_round(connection, expected):
23+
geom = MultiPolygon(expected, srid=4326)
24+
await connection.execute('INSERT INTO multipolygon_async (geom) '
25+
'VALUES ($1)', geom)
26+
geom = await connection.fetchval('SELECT geom FROM multipolygon_async '
27+
'WHERE geom=$1', geom, column=0)
28+
assert geom.coords == expected

tests/asyncpg/test_polygon.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
from postgis import Polygon
4+
5+
pytestmark = pytest.mark.asyncio
6+
7+
8+
@pytest.mark.parametrize('expected', [
9+
(((35, 10), (45, 45), (15, 40), (10, 20), (35, 10)), ((20, 30), (35, 35), (30, 20), (20, 30))), # noqa
10+
])
11+
async def test_polygon_should_round(connection, expected):
12+
geom = Polygon(expected, srid=4326)
13+
await connection.execute('INSERT INTO polygon_async (geom) VALUES ($1)',
14+
geom)
15+
geom = await connection.fetchval('SELECT geom FROM polygon_async WHERE '
16+
'geom=$1', geom, column=0)
17+
assert geom.coords == expected

0 commit comments

Comments
 (0)