Ejemplo n.º 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://zun')
     self.assertRaises(GatewayTimeout, client.json_request, 'GET',
                       '/v1/resources')
Ejemplo n.º 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://zun')

        client.json_request('GET', '/v1/services')
        self.assertEqual(
            fake_session.request.call_args[1]['endpoint_override'],
            'http://zun')