Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bunch of tests that were mismatched between sycn/async. #562

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/test_async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,12 @@ async def test_transaction_state(self):
INSERT test::Tmp { id := <uuid>$0, tmp := '' }
''', uuid.uuid4())

@unittest.expectedFailure
async def test_async_query_sql_01(self):
if await self.client.query_required_single('''
select sys::get_version().major < 6
'''):
self.skipTest("Buggy in versions earlier than 6.0")
Comment on lines +1156 to +1159
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens? Probably we want some useful error mode there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like, edgedb-python should refuse to do query_sql if it isn't on proto v3


res = await self.client.query_sql("SELECT 1")
self.assertEqual(res[0].as_dict(), {'col~1': 1})

Expand Down
68 changes: 34 additions & 34 deletions tests/test_postgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def tearDownClass(cls):
finally:
super().tearDownClass()

async def _test_postgis_geometry(self, wkt, wkb):
def _test_postgis_geometry(self, wkt, wkb):
val = self.client.query_single(f'''
with module ext::postgis
select <geometry>{wkt!r}
Expand All @@ -74,7 +74,7 @@ async def _test_postgis_geometry(self, wkt, wkb):
''', Geo(wkb=wkb))
self.assertTrue(val)

async def _test_postgis_geography(self, wkt, wkb):
def _test_postgis_geography(self, wkt, wkb):
val = self.client.query_single(f'''
with module ext::postgis
select <geography>{wkt!r}
Expand All @@ -89,42 +89,42 @@ async def _test_postgis_geography(self, wkt, wkb):
''', Geo(wkb=wkb))
self.assertTrue(val)

async def test_postgis_01(self):
await self._test_postgis_geometry(
def test_postgis_01(self):
self._test_postgis_geometry(
'point(1 2)',
b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0?\x00\x00'
b'\x00\x00\x00\x00\x00@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'point z (1 2 3)',
b'\x01\x01\x00\x00\x80\x00\x00\x00\x00\x00\x00\xf0?\x00\x00'
b'\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x08@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'point m (1 2 3)',
b'\x01\x01\x00\x00@\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00'
b'\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x08@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'point zm (1 2 3 4)',
b'\x01\x01\x00\x00\xc0\x00\x00\x00\x00\x00\x00\xf0?\x00\x00'
b'\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x08@\x00\x00'
b'\x00\x00\x00\x00\x10@',
)

async def test_postgis_02(self):
await self._test_postgis_geometry(
def test_postgis_02(self):
self._test_postgis_geometry(
'multipoint ((1 2), (4 5))',
b'\x01\x04\x00\x00\x00\x02\x00\x00\x00\x01\x01\x00\x00\x00\x00'
b'\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\x00@\x01'
b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10@\x00\x00\x00\x00'
b'\x00\x00\x14@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'multipoint z ((1 2 3), (4 5 6))',
b'\x01\x04\x00\x00\x80\x02\x00\x00\x00\x01\x01\x00\x00\x80\x00'
b'\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\x00@\x00'
Expand All @@ -133,16 +133,16 @@ async def test_postgis_02(self):
b'\x00\x18@',
)

async def test_postgis_03(self):
await self._test_postgis_geometry(
def test_postgis_03(self):
self._test_postgis_geometry(
'linestring (1 2, 3 4, 5 6)',
b'\x01\x02\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\xf0?\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x08'
b'@\x00\x00\x00\x00\x00\x00\x10@\x00\x00\x00\x00\x00\x00\x14@'
b'\x00\x00\x00\x00\x00\x00\x18@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'''polygon (
(0 0 0, 4 0 0, 4 4 0, 0 4 0, 0 0 0),
(1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0)
Expand All @@ -167,7 +167,7 @@ async def test_postgis_03(self):
b'\x00\x00',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'multilinestring ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))',
b'\x01\x05\x00\x00\x00\x02\x00\x00\x00\x01\x02\x00\x00\x00\x03'
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Expand All @@ -180,7 +180,7 @@ async def test_postgis_03(self):
b'\x00\x10@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'''multipolygon (
((1 5, 5 5, 5 1, 1 1, 1 5)), ((6 5, 9 1, 6 1, 6 5))
)''',
Expand All @@ -198,7 +198,7 @@ async def test_postgis_03(self):
b'\x00\x00\x00\x00\x18@\x00\x00\x00\x00\x00\x00\x14@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'geometrycollection ( point(2 3), linestring(2 3, 3 4))',
b'\x01\x07\x00\x00\x00\x02\x00\x00\x00\x01\x01\x00\x00\x00\x00'
b'\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x08@'
Expand All @@ -207,9 +207,9 @@ async def test_postgis_03(self):
b'\x00\x08@\x00\x00\x00\x00\x00\x00\x10@',
)

async def test_postgis_04(self):
def test_postgis_04(self):
# Extended WKB
await self._test_postgis_geometry(
self._test_postgis_geometry(
'''polyhedralsurface z (
((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),
Expand Down Expand Up @@ -274,7 +274,7 @@ async def test_postgis_04(self):
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0?',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'triangle ((0 0, 0 9, 9 0, 0 0))',
b'\x01\x11\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00\x00\x00'
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Expand All @@ -284,7 +284,7 @@ async def test_postgis_04(self):
b'\x00\x00',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'''tin z (
((0 0 0, 0 0 1, 0 1 0, 0 0 0)),
((0 0 0, 0 1 0, 1 1 0, 0 0 0))
Expand All @@ -307,17 +307,17 @@ async def test_postgis_04(self):
b'\x00\x00',
)

async def test_postgis_05(self):
def test_postgis_05(self):
# Curved geometry: extended WKB
await self._test_postgis_geometry(
self._test_postgis_geometry(
'circularstring(0 0, 1 1, 1 0)',
b'\x01\x08\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x00\xf0?\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00'
b'\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\x00\x00',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'compoundcurve( circularstring(0 0, 1 1, 1 0),(1 0, 0 1))',
b'\x01\t\x00\x00\x00\x02\x00\x00\x00\x01\x08\x00\x00\x00\x03'
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Expand All @@ -329,7 +329,7 @@ async def test_postgis_05(self):
b'\xf0?',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'''curvepolygon(
compoundcurve(
circularstring(0 0, 2 0, 2 1, 2 3, 4 3),
Expand Down Expand Up @@ -357,7 +357,7 @@ async def test_postgis_05(self):
b'3333\xfb?\x00\x00\x00\x00\x00\x00\xf0?',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'multicurve( (0 0, 5 5), circularstring(4 0, 4 4, 8 4))',
b'\x01\x0b\x00\x00\x00\x02\x00\x00\x00\x01\x02\x00\x00\x00\x02'
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Expand All @@ -369,7 +369,7 @@ async def test_postgis_05(self):
b'\x10@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'''multisurface(
curvepolygon(
circularstring(0 0, 4 0, 4 4, 0 4, 0 0),
Expand Down Expand Up @@ -404,35 +404,35 @@ async def test_postgis_05(self):
b'&@\x00\x00\x00\x00\x00\x00&@',
)

async def test_postgis_06(self):
def test_postgis_06(self):
# Geometry with SRID
await self._test_postgis_geometry(
self._test_postgis_geometry(
'srid=4; point(1 2)',
b'\x01\x01\x00\x00 \x04\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\xf0?\x00\x00\x00\x00\x00\x00\x00@',
)

await self._test_postgis_geometry(
self._test_postgis_geometry(
'srid=4267; point(1 2)',
b'\x01\x01\x00\x00 \xab\x10\x00\x00\x00\x00\x00\x00\x00\x00'
b'\xf0?\x00\x00\x00\x00\x00\x00\x00@',
)

async def test_postgis_07(self):
def test_postgis_07(self):
# Geography with SRID
await self._test_postgis_geography(
self._test_postgis_geography(
'point(1 2)',
b'\x01\x01\x00\x00 \xe6\x10\x00\x00\x00\x00\x00\x00\x00\x00'
b'\xf0?\x00\x00\x00\x00\x00\x00\x00@',
)

await self._test_postgis_geography(
self._test_postgis_geography(
'srid=4267; point(1 2)',
b'\x01\x01\x00\x00 \xab\x10\x00\x00\x00\x00\x00\x00\x00\x00'
b'\xf0?\x00\x00\x00\x00\x00\x00\x00@',
)

async def test_postgis_08(self):
def test_postgis_08(self):
text = 'box(0 1, 2 3)'
data = (
b'\x01\x03\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00'
Expand Down Expand Up @@ -470,7 +470,7 @@ async def test_postgis_08(self):
''', (Geo(wkb=data), 'ok'))
self.assertTrue(val)

async def test_postgis_09(self):
def test_postgis_09(self):
text = 'BOX3D(0 1 5, 2 3 9)'
data = (
b'\x01\x0f\x00\x00\x80\x06\x00\x00\x00\x01\x03\x00\x00\x80\x01'
Expand Down
6 changes: 3 additions & 3 deletions tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def tearDownClass(cls):
finally:
super().tearDownClass()

async def test_vector_01(self):
def test_vector_01(self):
val = self.client.query_single('''
select <ext::pgvector::vector>[1.5,2.0,3.8]
''')
Expand Down Expand Up @@ -139,7 +139,7 @@ async def test_vector_01(self):
'foo',
)

async def test_vector_02(self):
def test_vector_02(self):
if self.PGVECTOR_VER < (0, 7):
self.skipTest("need at least pgvector 0.7.4 for sparsevec")

Expand Down Expand Up @@ -209,7 +209,7 @@ async def test_vector_02(self):
{'dim': 6, 1: 1.5, 2: 2, 3: 0},
)

async def test_vector_03(self):
def test_vector_03(self):
if self.PGVECTOR_VER < (0, 7):
self.skipTest("need at least pgvector 0.7.4 for halfvec")

Expand Down
Loading