Fix the CI failure
Zaqar client's unit test is broken by requests after its version 2.12.0. This patch fixes it. Change-Id: I9f24e21923d41115555df033dcb5fd84975ba301
This commit is contained in:

committed by
Fei Long Wang

parent
ca76a31311
commit
2396dadeae
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
import requests as prequest
|
import requests as prequest
|
||||||
|
from requests.packages.urllib3 import response
|
||||||
|
|
||||||
from zaqarclient.tests import base
|
from zaqarclient.tests import base
|
||||||
from zaqarclient.tests.transport import api
|
from zaqarclient.tests.transport import api
|
||||||
@@ -31,7 +32,9 @@ class TestHttpTransport(base.TestBase):
|
|||||||
self.api = api.FakeApi()
|
self.api = api.FakeApi()
|
||||||
self.transport = http.HttpTransport(self.conf)
|
self.transport = http.HttpTransport(self.conf)
|
||||||
|
|
||||||
def test_basic_send(self):
|
@mock.patch.object(prequest.packages.urllib3.response.HTTPResponse,
|
||||||
|
'stream')
|
||||||
|
def test_basic_send(self, mock_stream):
|
||||||
params = {'name': 'Test',
|
params = {'name': 'Test',
|
||||||
'address': 'Outer space'}
|
'address': 'Outer space'}
|
||||||
req = request.Request('http://example.org/',
|
req = request.Request('http://example.org/',
|
||||||
@@ -42,6 +45,8 @@ class TestHttpTransport(base.TestBase):
|
|||||||
autospec=True) as request_method:
|
autospec=True) as request_method:
|
||||||
|
|
||||||
resp = prequest.Response()
|
resp = prequest.Response()
|
||||||
|
raw = response.HTTPResponse()
|
||||||
|
resp.raw = raw
|
||||||
request_method.return_value = resp
|
request_method.return_value = resp
|
||||||
|
|
||||||
# NOTE(flaper87): Bypass the API
|
# NOTE(flaper87): Bypass the API
|
||||||
@@ -61,7 +66,9 @@ class TestHttpTransport(base.TestBase):
|
|||||||
verify=True,
|
verify=True,
|
||||||
cert=None)
|
cert=None)
|
||||||
|
|
||||||
def test_send_without_api(self):
|
@mock.patch.object(prequest.packages.urllib3.response.HTTPResponse,
|
||||||
|
'stream')
|
||||||
|
def test_send_without_api(self, mock_stream):
|
||||||
params = {'name': 'Test',
|
params = {'name': 'Test',
|
||||||
'address': 'Outer space'}
|
'address': 'Outer space'}
|
||||||
req = request.Request('http://example.org/',
|
req = request.Request('http://example.org/',
|
||||||
@@ -72,6 +79,8 @@ class TestHttpTransport(base.TestBase):
|
|||||||
autospec=True) as request_method:
|
autospec=True) as request_method:
|
||||||
|
|
||||||
resp = prequest.Response()
|
resp = prequest.Response()
|
||||||
|
raw = response.HTTPResponse()
|
||||||
|
resp.raw = raw
|
||||||
request_method.return_value = resp
|
request_method.return_value = resp
|
||||||
self.transport.send(req)
|
self.transport.send(req)
|
||||||
|
|
||||||
@@ -85,7 +94,9 @@ class TestHttpTransport(base.TestBase):
|
|||||||
verify=True,
|
verify=True,
|
||||||
cert=None)
|
cert=None)
|
||||||
|
|
||||||
def test_error_handling(self):
|
@mock.patch.object(prequest.packages.urllib3.response.HTTPResponse,
|
||||||
|
'stream')
|
||||||
|
def test_error_handling(self, mock_stream):
|
||||||
params = {'name': 'Opportunity',
|
params = {'name': 'Opportunity',
|
||||||
'address': 'NASA'}
|
'address': 'NASA'}
|
||||||
req = request.Request('http://example.org/',
|
req = request.Request('http://example.org/',
|
||||||
@@ -100,6 +111,8 @@ class TestHttpTransport(base.TestBase):
|
|||||||
for response_code, exception in exception_iterator:
|
for response_code, exception in exception_iterator:
|
||||||
|
|
||||||
resp = prequest.Response()
|
resp = prequest.Response()
|
||||||
|
raw = response.HTTPResponse()
|
||||||
|
resp.raw = raw
|
||||||
resp.status_code = response_code
|
resp.status_code = response_code
|
||||||
request_method.return_value = resp
|
request_method.return_value = resp
|
||||||
self.assertRaises(exception, lambda: self.transport.send(req))
|
self.assertRaises(exception, lambda: self.transport.send(req))
|
||||||
|
Reference in New Issue
Block a user