Replace old httpclient with requests

This review implements blueprint python-request and replaces the old
http client implementation in favor of a new one based on
python-requests.

Major changes:
* raw_request and json_request removed since everything is now being
  handled by the same method "_request"
* New methods that match HTTP's methods were added:
    - get
    - put
    - post
    - head
    - patch
    - delete
* Content-Type is now being "inferred" based on the data being sent:
    - if it is file-like object it chunks the request
    - if it is a python type not instance of basestring then it'll try
      to serialize it to json
    - Every other case will keep the incoming content-type and will send
      the data as is.
* Glanceclient's HTTPSConnection implementation will be used if
  no-compression flag is set to True.

Co-Author:  Flavio Percoco<flaper87@gmail.com>
Change-Id: I09f70eee3e2777f52ce040296015d41649c2586a
This commit is contained in:
AmalaBasha
2014-07-01 14:45:12 +05:30
parent 1db17aaad9
commit dbb242b776
22 changed files with 744 additions and 1063 deletions
+16 -16
View File
@@ -224,81 +224,81 @@ class ShellInvalidEndpointandParameterTest(utils.TestCase):
def test_image_list_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint, self.run_command, 'image-list')
exc.CommunicationError, self.run_command, 'image-list')
def test_image_details_invalid_endpoint_legacy(self):
self.assertRaises(
exc.InvalidEndpoint, self.run_command, 'details')
exc.CommunicationError, self.run_command, 'details')
def test_image_update_invalid_endpoint_legacy(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'update {"name":""test}')
def test_image_index_invalid_endpoint_legacy(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'index')
def test_image_create_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'image-create')
def test_image_delete_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'image-delete <fake>')
def test_image_download_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'image-download <fake>')
def test_image_members_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'image-members fake_id')
def test_members_list_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'member-list --image-id fake')
def test_member_replace_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'members-replace image_id member_id')
def test_image_show_invalid_endpoint_legacy(self):
self.assertRaises(
exc.InvalidEndpoint, self.run_command, 'show image')
exc.CommunicationError, self.run_command, 'show image')
def test_image_show_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'image-show --human-readable <IMAGE_ID>')
def test_member_images_invalid_endpoint_legacy(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command, 'member-images member_id')
def test_member_create_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command,
'member-create --can-share <IMAGE_ID> <TENANT_ID>')
def test_member_delete_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command,
'member-delete <IMAGE_ID> <TENANT_ID>')
def test_member_add_invalid_endpoint(self):
self.assertRaises(
exc.InvalidEndpoint,
exc.CommunicationError,
self.run_command,
'member-add <IMAGE_ID> <TENANT_ID>')