Пример #1
0
 def test_exception(self):
     fake_response = utils.FakeSessionResponse({},
                                               content="",
                                               status_code=504)
     fake_session = mock.MagicMock()
     fake_session.request.side_effect = [fake_response]
     client = http.SessionClient(session=fake_session,
                                 endpoint_override='http://magnum')
     self.assertRaises(GatewayTimeout, client.json_request, 'GET',
                       '/v1/resources')
Пример #2
0
    def test_bypass_url(self):
        fake_response = utils.FakeSessionResponse({},
                                                  content="",
                                                  status_code=201)
        fake_session = mock.MagicMock()
        fake_session.request.side_effect = [fake_response]

        client = http.SessionClient(session=fake_session,
                                    endpoint_override='http://magnum')

        client.json_request('GET', '/v1/bays')
        self.assertEqual(
            fake_session.request.call_args[1]['endpoint_override'],
            'http://magnum')
Пример #3
0
    def test_raw_request(self):
        fake_response = utils.FakeSessionResponse(
            {'content-type': 'application/octet-stream'},
            content="",
            status_code=200)
        fake_session = mock.MagicMock()
        fake_session.request.side_effect = [fake_response]

        client = http.SessionClient(session=fake_session,
                                    endpoint_override='http://magnum')

        resp = client.raw_request('GET', '/v1/bays')

        self.assertEqual(
            fake_session.request.call_args[1]['headers']['Content-Type'],
            'application/octet-stream')
        self.assertEqual(fake_response, resp)