def test_constructor(self, prefix='0daf8h21'):
    dcon = {('%s.xyx' % prefix): {'exchange': ('%s.xyx' % prefix), 'routing_key': 'xyx'}, ('%s.xyz' % prefix): {'exchange': ('%s.xyz' % prefix), 'routing_key': 'xyz'}}
    consumers = [compat.Consumer(self.connection, queue=(prefix + str(i)), exchange=(prefix + str(i))) for i in range(3)]
    c = compat.ConsumerSet(self.connection, consumers=consumers)
    c2 = compat.ConsumerSet(self.connection, from_dict=dcon)
    self.assertEqual(len(c.queues), 3)
    self.assertEqual(len(c2.queues), 2)
    c.add_consumer(compat.Consumer(self.connection, queue=(prefix + 'xaxxxa'), exchange=(prefix + 'xaxxxa')))
    self.assertEqual(len(c.queues), 4)
    for cq in c.queues:
        self.assertIs(cq.channel, c.channel)
    c2.add_consumer_from_dict({('%s.xxx' % prefix): {'exchange': ('%s.xxx' % prefix), 'routing_key': 'xxx'}})
    self.assertEqual(len(c2.queues), 3)
    for c2q in c2.queues:
        self.assertIs(c2q.channel, c2.channel)
    c.discard_all()
    self.assertEqual(c.channel.called.count('queue_purge'), 4)
    c.consume()
    c.close()
    c2.close()
    self.assertIn('basic_cancel', c.channel)
    self.assertIn('close', c.channel)
    self.assertIn('close', c2.channel)
def test_constructor(self, prefix='0daf8h21'):
    dcon = {('%s.xyx' % prefix): {'exchange': ('%s.xyx' % prefix), 'routing_key': 'xyx'}, ('%s.xyz' % prefix): {'exchange': ('%s.xyz' % prefix), 'routing_key': 'xyz'}}
    consumers = [compat.Consumer(self.connection, queue=(prefix + str(i)), exchange=(prefix + str(i))) for i in range(3)]
    c = compat.ConsumerSet(self.connection, consumers=consumers)
    c2 = compat.ConsumerSet(self.connection, from_dict=dcon)
    self.assertEqual(len(c.queues), 3)
    self.assertEqual(len(c2.queues), 2)
    c.add_consumer(compat.Consumer(self.connection, queue=(prefix + 'xaxxxa'), exchange=(prefix + 'xaxxxa')))
    self.assertEqual(len(c.queues), 4)
    for cq in c.queues:
        self.assertIs(cq.channel, c.channel)
    c2.add_consumer_from_dict({('%s.xxx' % prefix): {'exchange': ('%s.xxx' % prefix), 'routing_key': 'xxx'}})
    self.assertEqual(len(c2.queues), 3)
    for c2q in c2.queues:
        self.assertIs(c2q.channel, c2.channel)
    c.discard_all()
    self.assertEqual(c.channel.called.count('queue_purge'), 4)
    c.consume()
    c.close()
    c2.close()
    self.assertIn('basic_cancel', c.channel)
    self.assertIn('close', c.channel)
    self.assertIn('close', c2.channel)