

def test_timeout_on_connect_reconnects(self):
    info = {
        'num_called': 0,
    }

    def _connect(rabbit_self):
        rabbit_self.connection_errors = ()
        info['num_called'] += 1
        if (info['num_called'] == 1):
            raise Exception('foo timeout foo')
        rabbit_self.connection = 'fake_connection'
    self.notify_kombu.RabbitStrategy._connect = _connect
    notifier_ = notifier.Notifier(self.conf)
    notifier_.error('test_event', 'test_message')
    if (self.called is False):
        self.fail('Did not call _send_message properly.')
    self.assertEquals('test_message', self.called['message']['payload'])
    self.assertEquals('ERROR', self.called['message']['priority'])
    self.assertEquals(info['num_called'], 2)

dataset/ETHPy150Open rcbops/glance-buildpackage/glance/tests/unit/test_notifier.py TestRabbitNotifier.test_timeout_on_connect_reconnects/original