示例#1
0
    def test_401(self):
        self.client_mock.get_queues.side_effect = HTTPError('', status=401)

        with self.assertRaises(RabbitCritical) as excinfo:
            get_queues(self.client_mock, self.vhost_mock)

        self.assertEqual(excinfo.exception.errors, {'all': ['Unauthorized.']})
        self.client_mock.get_queues.assert_called_once_with(self.vhost_mock)
示例#2
0
    def test_unknown_error(self):
        self.client_mock.get_queues.side_effect = HTTPError('', status=500)

        with self.assertRaises(RabbitCritical) as excinfo:
            get_queues(self.client_mock, self.vhost_mock)

        self.assertEqual(excinfo.exception.errors,
                         {'all': ['Unhandled HTTP error, status: 500']})
        self.client_mock.get_queues.assert_called_once_with(self.vhost_mock)
示例#3
0
    def test_network_error(self):
        self.client_mock.get_queues.side_effect = NetworkError()

        with self.assertRaises(RabbitCritical) as excinfo:
            get_queues(self.client_mock, self.vhost_mock)

        self.assertEqual(excinfo.exception.errors,
                         {'all': ['Can not communicate with RabbitMQ.']})
        self.client_mock.get_queues.assert_called_once_with(self.vhost_mock)
示例#4
0
    def test_ok(self):
        res = get_queues(self.client_mock, self.vhost_mock)

        self.assertEqual(res, self.client_mock.get_queues.return_value)
        self.client_mock.get_queues.assert_called_once_with(self.vhost_mock)