Skip to content

Commit e583887

Browse files
authored
Test 'Blob.compose' w/ 'user_project' set. (#4092)
1 parent 91bf76f commit e583887

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

storage/tests/system.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,32 @@ def test_compose_replace_existing_blob(self):
652652
composed = original.download_as_string()
653653
self.assertEqual(composed, BEFORE + TO_APPEND)
654654

655+
@unittest.skipUnless(USER_PROJECT, 'USER_PROJECT not set in environment.')
656+
def test_compose_with_user_project(self):
657+
new_bucket_name = 'compose-user-project' + unique_resource_id('-')
658+
created = Config.CLIENT.create_bucket(
659+
new_bucket_name, requester_pays=True)
660+
try:
661+
SOURCE_1 = b'AAA\n'
662+
source_1 = created.blob('source-1')
663+
source_1.upload_from_string(SOURCE_1)
664+
665+
SOURCE_2 = b'BBB\n'
666+
source_2 = created.blob('source-2')
667+
source_2.upload_from_string(SOURCE_2)
668+
669+
with_user_project = Config.CLIENT.bucket(
670+
new_bucket_name, user_project=USER_PROJECT)
671+
672+
destination = with_user_project.blob('destination')
673+
destination.content_type = 'text/plain'
674+
destination.compose([source_1, source_2])
675+
676+
composed = destination.download_as_string()
677+
self.assertEqual(composed, SOURCE_1 + SOURCE_2)
678+
finally:
679+
retry_429(created.delete)(force=True)
680+
655681

656682
class TestStorageRewrite(TestStorageFiles):
657683

0 commit comments

Comments
 (0)