]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: add test to reveal unexpected message received
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 5 Jun 2022 16:58:37 +0000 (18:58 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 5 Jun 2022 17:16:29 +0000 (19:16 +0200)
The test fails because we receive a notification:

    message type 0x33 arrived from server while idle

See issue #314.

tests/test_pipeline.py
tests/test_pipeline_async.py

index 841379bb9830b30422df1586185e523c7f36de6c..dd890f8496d8cf361c55a06cc0337d1b12b3ae53 100644 (file)
@@ -487,6 +487,18 @@ def test_rollback_transaction(conn):
     conn.execute("select 1")
 
 
+def test_message_0x33(conn):
+    notices = []
+    conn.add_notice_handler(lambda diag: notices.append(diag.message_primary))
+
+    conn.autocommit = True
+    with conn.pipeline():
+        cur = conn.execute("select 'test'")
+        cur.fetchone() == ("test",)
+
+    assert not notices
+
+
 def test_concurrency(conn):
     with conn.transaction():
         conn.execute("drop table if exists pipeline_concurrency")
index c170dfa23528e02c14c852863ce0f848c61a2720..ef929b3b1fc0b69f6cdb7be6132f40d33309bab1 100644 (file)
@@ -489,6 +489,18 @@ async def test_rollback_transaction(aconn):
     await aconn.execute("select 1")
 
 
+async def test_message_0x33(aconn):
+    notices = []
+    aconn.add_notice_handler(lambda diag: notices.append(diag.message_primary))
+
+    await aconn.set_autocommit(True)
+    async with aconn.pipeline():
+        cur = await aconn.execute("select 'test'")
+        await cur.fetchone() == ("test",)
+
+    assert not notices
+
+
 async def test_concurrency(aconn):
     async with aconn.transaction():
         await aconn.execute("drop table if exists pipeline_concurrency")