Skip to content

Commit

Permalink
Merge pull request #16 from RachelTucker/pythonsdk-87
Browse files Browse the repository at this point in the history
PYTHONSDK-87: networking bug fix so all requests with payloads send their payloads
  • Loading branch information
rpmoore authored Jan 24, 2018
2 parents 3b955d5 + 430aa4b commit 984f7b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ds3/ds3network.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def send_request(self, request):

headers.update(amz_headers)

if request.http_verb == HttpVerb.PUT or request.http_verb == HttpVerb.POST:
if request.body is not None and request.body is not "":
canonicalized_amz_header = self.canonicalized_amz_headers(amz_headers)
headers['Content-Type'] = 'application/octet-stream'
headers['Authorization'] = self.build_authorization(verb=request.http_verb,
Expand Down
20 changes: 20 additions & 0 deletions tests/clientTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,18 @@ def testGetObjectsWithFullDetails(self):

self.assertEqual(len(response.result['ObjectList']), 4)

def testVerifyPhysicalPlacement(self):
populateTestData(self.client, bucketName, self.getDataPolicyId())

object_list = FileObjectList([FileObject(name="beowulf.txt")])

request = VerifyPhysicalPlacementForObjectsSpectraS3Request(bucket_name=bucketName, object_list=object_list)

try:
self.client.verify_physical_placement_for_objects_spectra_s3(request)
except RequestFailed as err:
self.assertEqual(err.http_error_code, 404)


class ObjectMetadataTestCase(Ds3TestCase):
def testHeadObject(self):
Expand Down Expand Up @@ -1391,3 +1403,11 @@ def testGetBlobPersistence(self):

response = GetBlobPersistenceSpectraS3Response(mocked_response, mocked_request)
self.assertEqual(response.result, content)

def testVerifyPhysicalPlacementRequestPayload(self):
obj1 = FileObject(name="obj1")
obj2 = FileObject(name="obj2")
l = FileObjectList([obj1, obj2])

request = VerifyPhysicalPlacementForObjectsSpectraS3Request(bucket_name="bucketName", object_list=l)
self.assertEqual(request.body.decode(), '<Objects><Object Name="obj1" /><Object Name="obj2" /></Objects>')

0 comments on commit 984f7b6

Please sign in to comment.