def test_connection_get_first_channel_id(self): connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True) self.assertEqual(connection._last_channel_id, None) self.assertEqual( connection._get_next_available_channel_id(), 1 ) self.assertEqual(connection._last_channel_id, 1)
def test_connection_get_next_channel_id(self): connection = Connection('127.0.0.1', 'guest', 'guest', timeout=0.1, lazy=True) connection._channels[1] = None self.assertEqual(connection._get_next_available_channel_id(), 2)
def test_connection_get_channel_ids(self): connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True) self.assertEqual(connection._last_channel_id, None) connection._channels[1] = None for index in range(2, 100): channel_id = connection._get_next_available_channel_id() connection._channels[channel_id] = None self.assertEqual(channel_id, index) self.assertEqual(connection._last_channel_id, index)
def test_connection_get_channel_ids(self): connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True) self.assertEqual(connection._last_channel_id, None) connection._channels[1] = None for index in range(2, 100): channel_id = connection._get_next_available_channel_id() connection._channels[channel_id] = None self.assertEqual( channel_id, index ) self.assertEqual(connection._last_channel_id, index)
def test_connection_maximum_channels_reached(self): connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True) connection.set_state(connection.OPEN) for index in compatibility.RANGE(MAX_CHANNELS): channel_id = connection._get_next_available_channel_id() connection._channels[channel_id] = None self.assertEqual(connection._last_channel_id, index + 1) self.assertRaisesRegexp( AMQPConnectionError, 'reached the maximum number of channels %d' % MAX_CHANNELS, connection.channel, lazy=True)