def test_rewrite_response_without_resource(self):
    SOURCE_BLOB = 'source'
    DEST_BLOB = 'dest'
    DEST_BUCKET = 'other-bucket'
    TOKEN = 'TOKEN'
    RESPONSE = {'totalBytesRewritten': 33, 'objectSize': 42, 'done': False, 'rewriteToken': TOKEN}
    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)
def test_rewrite_response_without_resource(self):
    SOURCE_BLOB = 'source'
    DEST_BLOB = 'dest'
    DEST_BUCKET = 'other-bucket'
    TOKEN = 'TOKEN'
    RESPONSE = {'totalBytesRewritten': 33, 'objectSize': 42, 'done': False, 'rewriteToken': TOKEN}
    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)