diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-03 11:32:51 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-03 22:10:57 -0400 |
commit | 8bd8f6c5aa1e85907b1517a57a91997532f3ebd7 (patch) | |
tree | f0c017d15b4bd8c7e21f4652ba24661e47b4e4b2 /test/dialect/postgresql/test_async_pg_py3k.py | |
parent | 2cc49191e28bcf05d97787d6cdc561dd6815e847 (diff) | |
download | sqlalchemy-8bd8f6c5aa1e85907b1517a57a91997532f3ebd7.tar.gz |
simplify and publicize the asyncpg JSON(B) codec registrsation
Added overridable methods ``PGDialect_asyncpg.setup_asyncpg_json_codec``
and ``PGDialect_asyncpg.setup_asyncpg_jsonb_codec`` codec, which handle the
required task of registering JSON/JSONB codecs for these datatypes when
using asyncpg. The change is that methods are broken out as individual,
overridable methods to support third party dialects that need to alter or
disable how these particular codecs are set up.
Fixes: #7284
Change-Id: I3eac258fea61f3975bd03c428747f788813ce45e
Diffstat (limited to 'test/dialect/postgresql/test_async_pg_py3k.py')
-rw-r--r-- | test/dialect/postgresql/test_async_pg_py3k.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_async_pg_py3k.py b/test/dialect/postgresql/test_async_pg_py3k.py index 62c8f5dde..12917e976 100644 --- a/test/dialect/postgresql/test_async_pg_py3k.py +++ b/test/dialect/postgresql/test_async_pg_py3k.py @@ -13,6 +13,7 @@ from sqlalchemy.dialects.postgresql import ENUM from sqlalchemy.testing import async_test from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures +from sqlalchemy.testing import mock class AsyncPgTest(fixtures.TestBase): @@ -251,3 +252,22 @@ class AsyncPgTest(fixtures.TestBase): await conn.begin() await conn.rollback() + + @testing.combinations( + "setup_asyncpg_json_codec", + "setup_asyncpg_jsonb_codec", + argnames="methname", + ) + @async_test + async def test_codec_registration( + self, metadata, async_testing_engine, methname + ): + """test new hooks added for #7284""" + + engine = async_testing_engine() + with mock.patch.object(engine.dialect, methname) as codec_meth: + conn = await engine.connect() + adapted_conn = (await conn.get_raw_connection()).connection + await conn.close() + + eq_(codec_meth.mock_calls, [mock.call(adapted_conn)]) |