Skip to content

Commit aa44133

Browse files
committed
Test 'Bucket.get_blob' w/ 'user_project' set. (#4090)
1 parent 68b96b2 commit aa44133

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

storage/tests/system.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,28 @@ def test_copy_existing_file_with_user_project(self):
243243
for blob in to_delete:
244244
retry_429(blob.delete)()
245245

246+
@unittest.skipUnless(USER_PROJECT, 'USER_PROJECT not set in environment.')
247+
def test_bucket_get_blob_with_user_project(self):
248+
new_bucket_name = 'w-requester-pays' + unique_resource_id('-')
249+
data = b'DEADBEEF'
250+
created = Config.CLIENT.create_bucket(
251+
new_bucket_name, requester_pays=True)
252+
self.case_buckets_to_delete.append(new_bucket_name)
253+
self.assertEqual(created.name, new_bucket_name)
254+
self.assertTrue(created.requester_pays)
255+
256+
with_user_project = Config.CLIENT.bucket(
257+
new_bucket_name, user_project=USER_PROJECT)
258+
259+
self.assertIsNone(with_user_project.get_blob('nonesuch'))
260+
to_add = created.blob('blob-name')
261+
to_add.upload_from_string(data)
262+
try:
263+
found = with_user_project.get_blob('blob-name')
264+
self.assertEqual(found.download_as_string(), data)
265+
finally:
266+
to_add.delete()
267+
246268

247269
class TestStorageFiles(unittest.TestCase):
248270

0 commit comments

Comments
 (0)