def test_rewrite_other_bucket_other_name_no_encryption_partial(self):
    SOURCE_BLOB = 'source'
    DEST_BLOB = 'dest'
    DEST_BUCKET = 'other-bucket'
    TOKEN = 'TOKEN'
    RESPONSE = {'totalBytesRewritten': 33, 'objectSize': 42, 'done': False, 'rewriteToken': TOKEN, 'resource': {'etag': 'DEADBEEF'}}
    response = ({'status': http_client.OK}, RESPONSE)
    connection = _Connection(response)
    client = _Client(connection)
    source_bucket = _Bucket(client=client)
    source_blob = self._make_one(SOURCE_BLOB, bucket=source_bucket)
    dest_bucket = _Bucket(client=client, name=DEST_BUCKET)
    dest_blob = self._make_one(DEST_BLOB, bucket=dest_bucket)
    (token, rewritten, size) = dest_blob.rewrite(source_blob)
    self.assertEqual(token, TOKEN)
    self.assertEqual(rewritten, 33)
    self.assertEqual(size, 42)
    kw = connection._requested
    self.assertEqual(len(kw), 1)
    self.assertEqual(kw[0]['method'], 'POST')
    PATH = ('/b/name/o/%s/rewriteTo/b/%s/o/%s' % (SOURCE_BLOB, DEST_BUCKET, DEST_BLOB))
    self.assertEqual(kw[0]['path'], PATH)
    self.assertEqual(kw[0]['query_params'], {})
    SENT = {}
    self.assertEqual(kw[0]['data'], SENT)
    headers = {key.title(): str(value) for (key, value) in kw[0]['headers'].items()}
    self.assertNotIn('X-Goog-Copy-Source-Encryption-Algorithm', headers)
    self.assertNotIn('X-Goog-Copy-Source-Encryption-Key', headers)
    self.assertNotIn('X-Goog-Copy-Source-Encryption-Key-Sha256', headers)
    self.assertNotIn('X-Goog-Encryption-Algorithm', headers)
    self.assertNotIn('X-Goog-Encryption-Key', headers)
    self.assertNotIn('X-Goog-Encryption-Key-Sha256', headers)
def test_rewrite_other_bucket_other_name_no_encryption_partial(self):
    SOURCE_BLOB = 'source'
    DEST_BLOB = 'dest'
    DEST_BUCKET = 'other-bucket'
    TOKEN = 'TOKEN'
    RESPONSE = {'totalBytesRewritten': 33, 'objectSize': 42, 'done': False, 'rewriteToken': TOKEN, 'resource': {'etag': 'DEADBEEF'}}
    response = ({'status': http_client.OK}, RESPONSE)
    connection = _Connection(response)
    client = _Client(connection)
    source_bucket = _Bucket(client=client)
    source_blob = self._make_one(SOURCE_BLOB, bucket=source_bucket)
    dest_bucket = _Bucket(client=client, name=DEST_BUCKET)
    dest_blob = self._make_one(DEST_BLOB, bucket=dest_bucket)
    (token, rewritten, size) = dest_blob.rewrite(source_blob)
    self.assertEqual(token, TOKEN)
    self.assertEqual(rewritten, 33)
    self.assertEqual(size, 42)
    kw = connection._requested
    self.assertEqual(len(kw), 1)
    self.assertEqual(kw[0]['method'], 'POST')
    PATH = ('/b/name/o/%s/rewriteTo/b/%s/o/%s' % (SOURCE_BLOB, DEST_BUCKET, DEST_BLOB))
    self.assertEqual(kw[0]['path'], PATH)
    self.assertEqual(kw[0]['query_params'], {})
    SENT = {}
    self.assertEqual(kw[0]['data'], SENT)
    headers = {key.title(): str(value) for (key, value) in kw[0]['headers'].items()}
    self.assertNotIn('X-Goog-Copy-Source-Encryption-Algorithm', headers)
    self.assertNotIn('X-Goog-Copy-Source-Encryption-Key', headers)
    self.assertNotIn('X-Goog-Copy-Source-Encryption-Key-Sha256', headers)
    self.assertNotIn('X-Goog-Encryption-Algorithm', headers)
    self.assertNotIn('X-Goog-Encryption-Key', headers)
    self.assertNotIn('X-Goog-Encryption-Key-Sha256', headers)