def testGenerateUploadUrl(self):
    content = 'hello world'
    # Generate hash of content.
    hasher = hashlib.md5()
    hasher.update(content)
    md5 = base64.b64encode(hasher.digest())

    upload_url = self.object_store.GenerateUploadUrl(self.key,
                                                     content_type='text/plain',
                                                     content_md5=md5,
                                                     expires_in=100, max_bytes=1024)
    headers = {'Content-Type': 'text/plain',
               'Content-MD5': md5}

    # Change uploaded content slightly to violate MD5 hash.
    self.assertRaises(httpclient.HTTPError, httpclient.HTTPClient().fetch,
      upload_url, method='PUT', headers=headers, body=content + '-')

    # Now upload correct content.
    response = httpclient.HTTPClient().fetch(upload_url, method='PUT', headers=headers, body=content)
    self.assertEqual(response.code, 200)

    value = self._RunAsync(self.object_store.Get, self.key)
    self.assertEqual(value, content)
Test GenerateUploadUrl method on S3 object store.
dataset/ETHPy150Open viewfinderco/viewfinder/backend/storage/test/s3_object_store_test.py/S3ObjectStoreTestCase.testGenerateUploadUrl