def test_log_request_id(self, mock_log_request_id): self.requests_mock.get('http://no.where') client = novaclient.client.SessionClient(session=session.Session(), service_name='compute') client.request("http://no.where", 'GET') mock_log_request_id.assert_called_once_with(client.logger, mock.ANY, 'compute')
def test_log_request_id(self, mock_log_request_id, mock_request): response = mock.MagicMock(status_code=200) mock_request.return_value = (response, None) client = novaclient.client.SessionClient(session=mock.MagicMock(), service_name='compute') client.request("http://no.where", 'GET') mock_log_request_id.assert_called_once_with(client.logger, response, 'compute')
def test_global_id(self): global_id = "req-%s" % uuidutils.generate_uuid() self.requests_mock.get('http://no.where') client = novaclient.client.SessionClient(session=session.Session(), global_request_id=global_id) client.request("http://no.where", 'GET') headers = self.requests_mock.last_request.headers self.assertEqual(headers['X-OpenStack-Request-ID'], global_id)
def test_timings(self, m_request): m_request.return_value = (mock.MagicMock(status_code=200), None) client = novaclient.client.SessionClient(session=mock.MagicMock()) client.request("http://no.where", "GET") self.assertEqual(0, len(client.times)) client = novaclient.client.SessionClient(session=mock.MagicMock(), timings=True) client.request("http://no.where", "GET") self.assertEqual(1, len(client.times)) self.assertEqual("GET http://no.where", client.times[0][0])
def test_timings(self, mock_log_request_id, m_request): m_request.return_value = (mock.MagicMock(status_code=200), None) client = novaclient.client.SessionClient(session=mock.MagicMock()) client.request("http://no.where", 'GET') self.assertEqual(0, len(client.times)) client = novaclient.client.SessionClient(session=mock.MagicMock(), timings=True) client.request("http://no.where", 'GET') self.assertEqual(1, len(client.times)) self.assertEqual('GET http://no.where', client.times[0][0])
def test_timings(self): self.requests_mock.get('http://no.where') client = novaclient.client.SessionClient(session=session.Session()) client.request("http://no.where", 'GET') self.assertEqual(0, len(client.times)) client = novaclient.client.SessionClient(session=session.Session(), timings=True) client.request("http://no.where", 'GET') self.assertEqual(1, len(client.times)) self.assertEqual('GET http://no.where', client.times[0][0])
def test_timings(self, mock_log_request_id): self.requests_mock.get('http://no.where') client = novaclient.client.SessionClient(session=session.Session()) client.request("http://no.where", 'GET') self.assertEqual(0, len(client.times)) client = novaclient.client.SessionClient(session=session.Session(), timings=True) client.request("http://no.where", 'GET') self.assertEqual(1, len(client.times)) self.assertEqual('GET http://no.where', client.times[0][0])