Merge "Fix wrong attribute name used for http status"

This commit is contained in:
Jenkins 2014-07-02 13:30:38 +00:00 committed by Gerrit Code Review
commit 5b7b9b343f
2 changed files with 7 additions and 7 deletions

View File

@ -83,7 +83,7 @@ class TempestConf(object):
msg = _('Error on downloading cirros image, possibly'
' no connection to Internet with message %s') % str(err)
raise exceptions.TempestConfigCreationFailure(message=msg)
if response.http_status == 200:
if response.status_code == 200:
with open(self.img_path + '.tmp', 'wb') as img_file:
for chunk in response.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
@ -91,7 +91,7 @@ class TempestConf(object):
img_file.flush()
os.rename(self.img_path + '.tmp', self.img_path)
else:
if response.http_status == 404:
if response.status_code == 404:
msg = _('Error on downloading cirros image, possibly'
'invalid cirros_version or cirros_image in rally.conf')
else:
@ -227,7 +227,7 @@ class TempestConf(object):
str(service in self.available_services))
horizon_url = ('http://' +
urlparse.urlparse(self.endpoint['auth_url']).hostname)
horizon_availability = (requests.get(horizon_url).http_status == 200)
horizon_availability = (requests.get(horizon_url).status_code == 200)
# convert boolean to string because ConfigParser fails
# on attempt to get option with boolean value
self.conf.set(section_name, 'horizon', str(horizon_availability))

View File

@ -55,7 +55,7 @@ class ConfigTestCase(test.TestCase):
@mock.patch("six.moves.builtins.open")
def test__load_img_success(self, mock_open, mock_rename, mock_requests):
mock_result = mock.MagicMock()
mock_result.http_status = 200
mock_result.status_code = 200
mock_requests.get.return_value = mock_result
mock_file = mock.MagicMock()
mock_open.return_value = mock_file
@ -68,7 +68,7 @@ class ConfigTestCase(test.TestCase):
@mock.patch("rally.verification.verifiers.tempest.config.requests")
def test__load_img_notfound(self, mock_requests):
mock_result = mock.MagicMock()
mock_result.http_status = 404
mock_result.status_code = 404
mock_requests.get.return_value = mock_result
self.assertRaises(exceptions.TempestConfigCreationFailure,
self.conf_generator._load_img)
@ -272,7 +272,7 @@ class ConfigTestCase(test.TestCase):
@mock.patch("rally.verification.verifiers.tempest.config.requests")
def test__set_service_available(self, mock_requests):
mock_result = mock.MagicMock()
mock_result.http_status = 404
mock_result.status_code = 404
mock_requests.get.return_value = mock_result
available_services = ("nova", "cinder", "glance")
self.conf_generator.available_services = available_services
@ -288,7 +288,7 @@ class ConfigTestCase(test.TestCase):
@mock.patch("rally.verification.verifiers.tempest.config.requests")
def test__set_service_available_horizon(self, mock_requests):
mock_result = mock.MagicMock()
mock_result.http_status = 200
mock_result.status_code = 200
mock_requests.get.return_value = mock_result
self.conf_generator._set_service_available()
self.assertEqual(self.conf_generator.conf.get(