Skip to content

Commit

Permalink
Merge pull request #946 from vitaly-krugl/is_closed-test
Browse files Browse the repository at this point in the history
Implemented BlockingConnection test TestLostConnectionResultsInIsClosedConnectionAndChannel
  • Loading branch information
lukebakken committed Feb 5, 2018
2 parents a7fed21 + 6840da3 commit 1b76018
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/acceptance/blocking_adapter_test.py
Expand Up @@ -149,6 +149,25 @@ def test(self):
self.assertTrue(connection.is_closed)


class TestLostConnectionResultsInIsClosedConnectionAndChannel(BlockingTestCaseBase):
def test(self):
connection = self._connect()
channel = connection.channel()

# Simulate the server dropping the socket connection
connection._impl.socket.shutdown(socket.SHUT_RDWR)

with self.assertRaises(pika.exceptions.ConnectionClosed):
# Changing QoS should result in ConnectionClosed
channel.basic_qos()

# Now check is_open/is_closed on channel and connection
self.assertFalse(channel.is_open)
self.assertTrue(channel.is_closed)
self.assertFalse(connection.is_open)
self.assertTrue(connection.is_closed)


class TestInvalidExchangeTypeRaisesConnectionClosed(BlockingTestCaseBase):
def test(self):
"""BlockingConnection: ConnectionClosed raised when creating exchange with invalid type""" # pylint: disable=C0301
Expand Down

0 comments on commit 1b76018

Please sign in to comment.