Passing SUPPORTED_ONEVIEW_VERSION as string + transient error fix
requests==2.11.0 is now checking header parameters for string or buffer types. We were passing SUPPORTED_ONEVIEW_VERSION as int, but now it's not allowed. This patch str's SUPPORTED_ONEVIEW_VERSION before passing it to requests. This patch also fixes a transient error occuring due to simultaneous access to constants in 'fixtures.py'. Change-Id: I188914c0f1c6a1c8496da59857e99ff03a2b83e6
This commit is contained in:
		| @@ -149,7 +149,7 @@ class BaseClient(object): | ||||
|  | ||||
|             headers = { | ||||
|                 'content-type': 'application/json', | ||||
|                 'X-Api-Version': SUPPORTED_ONEVIEW_VERSION, | ||||
|                 'X-Api-Version': str(SUPPORTED_ONEVIEW_VERSION), | ||||
|                 'Auth': self.session_id | ||||
|             } | ||||
|             url = '%s%s' % (self.manager_url, uri) | ||||
|   | ||||
| @@ -15,6 +15,7 @@ | ||||
| #    See the License for the specific language governing permissions and | ||||
| #    limitations under the License. | ||||
|  | ||||
| import copy | ||||
| import mock | ||||
| import requests | ||||
| import six.moves.http_client as http_client | ||||
| @@ -140,8 +141,9 @@ class OneViewClientTestCase(unittest.TestCase): | ||||
|         ) | ||||
|         profile = mock.MagicMock() | ||||
|         profile.status_code = http_client.OK | ||||
|         profile_fixture = copy.deepcopy(fixtures.SERVER_PROFILE_JSON) | ||||
|         profile.json = mock.MagicMock( | ||||
|             return_value=fixtures.SERVER_PROFILE_JSON | ||||
|             return_value=profile_fixture | ||||
|         ) | ||||
|         mock_get.side_effect = [hardware, profile] | ||||
|  | ||||
| @@ -179,8 +181,9 @@ class OneViewClientTestCase(unittest.TestCase): | ||||
|         ) | ||||
|         profile = mock.MagicMock() | ||||
|         profile.status_code = http_client.OK | ||||
|         profile_fixture = copy.deepcopy(fixtures.SERVER_PROFILE_JSON) | ||||
|         profile.json = mock.MagicMock( | ||||
|             return_value=fixtures.SERVER_PROFILE_JSON | ||||
|             return_value=profile_fixture | ||||
|         ) | ||||
|         mock_get.side_effect = [hardware, profile] | ||||
|  | ||||
| @@ -307,8 +310,9 @@ class OneViewClientTestCase(unittest.TestCase): | ||||
|         ) | ||||
|         profile = mock.MagicMock() | ||||
|         profile.status_code = http_client.OK | ||||
|         profile_fixture = copy.deepcopy(fixtures.SERVER_PROFILE_JSON) | ||||
|         profile.json = mock.MagicMock( | ||||
|             return_value=fixtures.SERVER_PROFILE_JSON | ||||
|             return_value=profile_fixture | ||||
|         ) | ||||
|         mock_get.side_effect = [hardware, profile, hardware, profile] | ||||
|         oneview_client._wait_for_task_to_complete = mock__wait_for_task | ||||
| @@ -320,7 +324,7 @@ class OneViewClientTestCase(unittest.TestCase): | ||||
|  | ||||
|         oneview_client.set_boot_device(node_info, 'PXE') | ||||
|         mock_put.assert_called_once_with( | ||||
|             self.manager_url + fixtures.SERVER_PROFILE_JSON.get('uri'), | ||||
|             self.manager_url + profile_fixture.get('uri'), | ||||
|             data=mock.ANY, | ||||
|             headers=mock.ANY, | ||||
|             verify=True | ||||
| @@ -347,8 +351,9 @@ class OneViewClientTestCase(unittest.TestCase): | ||||
|         ) | ||||
|         profile = mock.MagicMock() | ||||
|         profile.status_code = http_client.OK | ||||
|         profile_fixture = copy.deepcopy(fixtures.SERVER_PROFILE_JSON) | ||||
|         profile.json = mock.MagicMock( | ||||
|             return_value=fixtures.SERVER_PROFILE_JSON | ||||
|             return_value=profile_fixture | ||||
|         ) | ||||
|         ilo_system = mock.MagicMock() | ||||
|         ilo_system.status_code = http_client.OK | ||||
| @@ -651,8 +656,9 @@ class OneViewClientV2TestCase(unittest.TestCase): | ||||
|                                          self.password) | ||||
|         response = mock_get.return_value | ||||
|         response.status_code = http_client.OK | ||||
|         profile_fixture = copy.deepcopy(fixtures.SERVER_PROFILE_JSON) | ||||
|         response.json = mock.MagicMock( | ||||
|             return_value=fixtures.SERVER_PROFILE_JSON | ||||
|             return_value=profile_fixture | ||||
|         ) | ||||
|         mock_get.return_value = response | ||||
|  | ||||
|   | ||||
| @@ -303,8 +303,9 @@ class OneViewClientTestCase(unittest.TestCase): | ||||
|             models.ServerHardware.from_json(fixtures.SERVER_HARDWARE_JSON) | ||||
|         ) | ||||
|         mock_get_server_hardware.return_value = server_hardware | ||||
|         profile = copy.deepcopy(fixtures.SERVER_PROFILE_JSON) | ||||
|         mock_get_server_profile.return_value = ( | ||||
|             models.ServerProfile.from_json(fixtures.SERVER_PROFILE_JSON) | ||||
|             models.ServerProfile.from_json(profile) | ||||
|         ) | ||||
|         expected_profile = copy.deepcopy(fixtures.SERVER_PROFILE_JSON) | ||||
|         expected_profile['boot'] = { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Thiago Paiva
					Thiago Paiva