diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2015-06-02 17:02:04 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2015-06-02 17:02:04 +0100 |
commit | 1f330e9cac9c5d40c33f4f58d0dbfc0109c62edc (patch) | |
tree | 0e4d67997ee734ac3025774a163c031e8a217b7b /tests/test_notify.py | |
parent | 2ad82b973b86fa71126657aacee89a30d2211894 (diff) | |
download | psycopg2-1f330e9cac9c5d40c33f4f58d0dbfc0109c62edc.tar.gz |
Allow connection.notices and notifies to be replaced.
Close #326
Diffstat (limited to 'tests/test_notify.py')
-rwxr-xr-x | tests/test_notify.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_notify.py b/tests/test_notify.py index f838389..fc6224d 100755 --- a/tests/test_notify.py +++ b/tests/test_notify.py @@ -155,6 +155,27 @@ conn.close() self.assertEqual('foo', notify.channel) self.assertEqual('Hello, world!', notify.payload) + def test_notify_deque(self): + from collections import deque + self.autocommit(self.conn) + self.conn.notifies = deque() + self.listen('foo') + self.notify('foo').communicate() + time.sleep(0.5) + self.conn.poll() + notify = self.conn.notifies.popleft() + self.assert_(isinstance(notify, psycopg2.extensions.Notify)) + self.assertEqual(len(self.conn.notifies), 0) + + def test_notify_noappend(self): + self.autocommit(self.conn) + self.conn.notifies = None + self.listen('foo') + self.notify('foo').communicate() + time.sleep(0.5) + self.conn.poll() + self.assertEqual(self.conn.notifies, None) + def test_notify_init(self): n = psycopg2.extensions.Notify(10, 'foo') self.assertEqual(10, n.pid) @@ -192,6 +213,7 @@ conn.close() self.assertNotEqual(hash(Notify(10, 'foo', 'bar')), hash(Notify(10, 'foo'))) + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) |