Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: py/utils/gs_utils_manualtest.py

Issue 661563002: Add does_storage_object_exist to gs_utils (Closed) Base URL: https://skia.googlesource.com/common.git@master
Patch Set: Work harder to find .boto Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« py/utils/gs_utils.py ('K') | « py/utils/gs_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """Tests for gs_utils.py. 3 """Tests for gs_utils.py.
4 4
5 TODO(epoger): How should we exercise these self-tests? See http://skbug.com/2751 5 TODO(epoger): How should we exercise these self-tests? See http://skbug.com/2751
6 """ 6 """
7 7
8 # System-level imports. 8 # System-level imports.
9 import os 9 import os
10 import posixpath 10 import posixpath
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 file_contents = f.read() 381 file_contents = f.read()
382 assert file_contents == 'contents of %s\n' % filename, ( 382 assert file_contents == 'contents of %s\n' % filename, (
383 '%s == "contents of %s\n"' % (file_contents, filename)) 383 '%s == "contents of %s\n"' % (file_contents, filename))
384 finally: 384 finally:
385 shutil.rmtree(local_dest_dir) 385 shutil.rmtree(local_dest_dir)
386 for filename in filenames: 386 for filename in filenames:
387 gs.delete_file(bucket=TEST_BUCKET, 387 gs.delete_file(bucket=TEST_BUCKET,
388 path=posixpath.join(remote_dir, subdir, filename)) 388 path=posixpath.join(remote_dir, subdir, filename))
389 389
390 390
391 def _test_does_storage_object_exist():
392 gs = gs_utils.GSUtils()
393 cases = (('gs_utils_manualtest/4843645167453050644/subdir/file1', True),
394 ('gs_utils_manualtest', True),
395 ('bogus', False))
396 for obj, expect in cases:
397 msg = 'expected exists(%s) to be %s' % (
398 '/'.join(('gs:/', TEST_BUCKET, obj)), expect)
399 assert gs.does_storage_object_exist(TEST_BUCKET, obj) == expect, msg
400
401
391 if __name__ == '__main__': 402 if __name__ == '__main__':
392 _test_static_methods() 403 _test_static_methods()
393 _test_upload_if_multiple_files() 404 _test_upload_if_multiple_files()
394 _test_upload_if_one_file() 405 _test_upload_if_one_file()
395 _test_public_read() 406 _test_public_read()
396 _test_authenticated_round_trip() 407 _test_authenticated_round_trip()
397 _test_dir_upload_and_download() 408 _test_dir_upload_and_download()
409 _test_does_storage_object_exist()
398 # TODO(epoger): Add _test_unauthenticated_access() to make sure we raise 410 # TODO(epoger): Add _test_unauthenticated_access() to make sure we raise
399 # an exception when we try to access without needed credentials. 411 # an exception when we try to access without needed credentials.
OLDNEW
« py/utils/gs_utils.py ('K') | « py/utils/gs_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698