From d84c854174f0e2dd30b8f2626c1fa56a8702c197 Mon Sep 17 00:00:00 2001 From: Rohan Kanade Date: Wed, 2 Jul 2014 14:05:03 +0200 Subject: [PATCH] Fix wrong attribute name used for http status * Use status_code instead of incorrect http_status Change-Id: I464f28dcdf96542b8d5420133f13d4150da37aaa Closes-Bug: #1335154 --- rally/verification/verifiers/tempest/config.py | 6 +++--- tests/verification/verifiers/test_config.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rally/verification/verifiers/tempest/config.py b/rally/verification/verifiers/tempest/config.py index cc450d0a89..25c79ab908 100644 --- a/rally/verification/verifiers/tempest/config.py +++ b/rally/verification/verifiers/tempest/config.py @@ -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)) diff --git a/tests/verification/verifiers/test_config.py b/tests/verification/verifiers/test_config.py index b32ade4a4a..2f9e40751d 100644 --- a/tests/verification/verifiers/test_config.py +++ b/tests/verification/verifiers/test_config.py @@ -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(