summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-04-05 18:24:19 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-04-05 19:04:48 +0100
commit46106e1b78334114f533d4979e8d9267654f9cbd (patch)
tree2ddf53ce81dededf82037f32f27319aa178e2eab
parent755a128ffbeef2813a1f5bcf1bbba629f37f0f49 (diff)
downloadpsycopg2-46106e1b78334114f533d4979e8d9267654f9cbd.tar.gz
Test notifies are received ok polling an async curfix-887
-rwxr-xr-xtests/test_async.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_async.py b/tests/test_async.py
index 618c158..f14468e 100755
--- a/tests/test_async.py
+++ b/tests/test_async.py
@@ -497,7 +497,28 @@ class AsyncTests(ConnectingTestCase):
def test_poll_noop(self):
self.conn.poll()
- self.conn.poll()
+
+ @skip_before_postgres(9, 0)
+ def test_poll_conn_for_notification(self):
+ with self.conn.cursor() as cur:
+ cur.execute("listen test")
+ self.wait(cur)
+
+ with self.sync_conn.cursor() as cur:
+ cur.execute("notify test, 'hello'")
+ self.sync_conn.commit()
+
+ for i in range(10):
+ self.conn.poll()
+
+ if self.conn.notifies:
+ n = self.conn.notifies.pop()
+ self.assertEqual(n.channel, 'test')
+ self.assertEqual(n.payload, 'hello')
+ break
+ time.sleep(0.1)
+ else:
+ self.fail("No notification received")
def test_suite():