예제 #1
0
class DescribeOnConnectionClose(_BaseTestCase):
    def configure(self):
        self.agent = ConsumerAgent(sentinel.consumer, sentinel.broker,
                                   sentinel.bindings)
        self.agent.connection = MagicMock()
        self.agent.channel = sentinel.channel
        self.agent._consumer_tags = sentinel._consumer_tags

    def execute(self):
        self.agent.on_connection_close(sentinel.connection,
                                       sentinel.reply_code,
                                       sentinel.reply_text)

    def should_reinitialize_channel(self):
        self.assertIsNone(self.agent.channel)

    def should_reinitialize_consumer_tags(self):
        self.assertEqual(self.agent._consumer_tags, {})

    def should_schedule_reconnection(self):
        self.agent.connection.add_timeout.assert_called_once_with(
            self.agent._RECONNECT_DELAY, self.agent.connect)
예제 #2
0
class DescribeOnConnectionClose(_BaseTestCase):

    def configure(self):
        self.agent = ConsumerAgent(sentinel.consumer, sentinel.broker,
                                   sentinel.bindings)
        self.agent.connection = MagicMock()
        self.agent.channel = sentinel.channel
        self.agent._consumer_tags = sentinel._consumer_tags

    def execute(self):
        self.agent.on_connection_close(sentinel.connection,
                                       sentinel.reply_code,
                                       sentinel.reply_text)

    def should_reinitialize_channel(self):
        self.assertIsNone(self.agent.channel)

    def should_reinitialize_consumer_tags(self):
        self.assertEqual(self.agent._consumer_tags, {})

    def should_schedule_reconnection(self):
        self.agent.connection.add_timeout.assert_called_once_with(
            self.agent._RECONNECT_DELAY, self.agent.connect)