diff options
author | Ask Solem <ask@celeryproject.org> | 2013-06-18 12:06:49 +0100 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2013-06-18 12:06:49 +0100 |
commit | e993cff0416c289742f04dd5eb19cd89da1d0d8f (patch) | |
tree | 86ddd1d62b441f1a2be2bb08680ead0e54c830e5 /kombu/tests/test_connection.py | |
parent | 9204bed46dd3c639ed9557fee8e795ffe92efa76 (diff) | |
download | kombu-e993cff0416c289742f04dd5eb19cd89da1d0d8f.tar.gz |
More connection tests
Diffstat (limited to 'kombu/tests/test_connection.py')
-rw-r--r-- | kombu/tests/test_connection.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/kombu/tests/test_connection.py b/kombu/tests/test_connection.py index 1211e8e4..be16b3f4 100644 --- a/kombu/tests/test_connection.py +++ b/kombu/tests/test_connection.py @@ -169,6 +169,46 @@ class test_Connection(TestCase): self.assertEqual(conn2.hostname, 'foo') self.assertListEqual(conn2.alt, ['amqp://foo', 'amqp://bar']) + def test_collect(self): + connection = Connection('memory://') + trans = connection._transport = Mock(name='transport') + _collect = trans._collect = Mock(name='transport._collect') + _close = connection._close = Mock(name='connection._close') + connection.declared_entities = Mock(name='decl_entities') + uconn = connection._connection = Mock(name='_connection') + connection.collect() + + self.assertFalse(_close.called) + _collect.assert_called_with(uconn) + connection.declared_entities.clear.assert_called_with() + self.assertIsNone(trans.client) + self.assertIsNone(connection._transport) + self.assertIsNone(connection._connection) + + def test_collect_no_transport(self): + connection = Connection('memory://') + connection._transport = None + connection._close = Mock() + connection.collect() + connection._close.assert_called_with() + + connection._close.side_effect = socket.timeout() + connection.collect() + + def test_collect_transport_gone(self): + connection = Connection('memory://') + uconn = connection._connection = Mock(name='conn._conn') + trans = connection._transport = Mock(name='transport') + collect = trans._collect = Mock(name='transport._collect') + + def se(conn): + connection._transport = None + collect.side_effect = se + + connection.collect() + collect.assert_called_with(uconn) + self.assertIsNone(connection._transport) + def test_uri_passthrough(self): from kombu import connection as mod prev, mod.URI_PASSTHROUGH = mod.URI_PASSTHROUGH, set(['foo']) @@ -270,6 +310,12 @@ class test_Connection(TestCase): c = Connection('amqp://example.com') self.assertEqual(copy(c).info(), c.info()) + def test_copy_multiples(self): + c = Connection('amqp://A.example.com;amqp://B.example.com') + self.assertTrue(c.alt) + d = copy(c) + self.assertEqual(d.alt, c.alt) + def test_switch(self): c = Connection('amqp://foo') c._closed = True |