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

Unified Diff: py/utils/gs_utils_manualtest.py

Issue 427893002: add is_gs_url(), split_gs_url() static methods to gs_utils.py (Closed) Base URL: https://skia.googlesource.com/common.git@master
Patch Set: Ravi comments Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « py/utils/gs_utils.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: py/utils/gs_utils_manualtest.py
diff --git a/py/utils/gs_utils_manualtest.py b/py/utils/gs_utils_manualtest.py
index 37621d1e70cdcf6e27fa456c3bd00bb4b80dc2af..3365055d0d140c32e97dfe4c48991da0980a612a 100755
--- a/py/utils/gs_utils_manualtest.py
+++ b/py/utils/gs_utils_manualtest.py
@@ -39,6 +39,40 @@ def _get_unique_posix_dir():
return 'gs_utils_manualtest/%d' % random.randint(0, sys.maxint)
+def _test_static_methods():
+ """Test all static methods."""
+ gs = gs_utils.GSUtils
+
+ # (input url, output bucket, output path) for each test case
+ testcases = [
+ (None, None, None),
+ (5, None, None),
+ ('', None, None),
+ ('/one/two', None, None),
+ ('http://one/two', None, None),
+ ('gs:', None, None),
+ ('gs://', None, None),
+ ('gs:///', None, None),
+ ('gs://???', None, None),
+ ('gs:///bucket', None, None),
+ ('gs://bucket', 'bucket', ''),
+ ('GS://bucket/', 'bucket', ''),
+ ('gs://bucket//', 'bucket', ''),
+ ('gs://bucket/path1', 'bucket', 'path1'),
+ ('gs://bucket/path1/path2', 'bucket', 'path1/path2'),
+ ('gs://bucket/path1/path2/', 'bucket', 'path1/path2'),
+ ('gs://bucket///path1/path2///', 'bucket', 'path1/path2'),
+ ('gs://bucket///path1//path2///', 'bucket', 'path1//path2'),
+ ]
+ for (url, bucket, path) in testcases:
+ is_legal_url = (bucket != None)
+ assert gs.is_gs_url(url) == is_legal_url, 'gs.is_gs_url("%s") == %s' % (
+ url, is_legal_url)
+ if is_legal_url:
+ assert gs.split_gs_url(url) == (bucket, path), (
+ 'gs.split_gs_url("%s") == ("%s", "%s")' % (url, bucket, path))
+
+
def _test_public_read():
"""Make sure we can read from public files without .boto file credentials."""
gs = gs_utils.GSUtils()
@@ -355,6 +389,7 @@ def _test_dir_upload_and_download():
if __name__ == '__main__':
+ _test_static_methods()
_test_upload_if_multiple_files()
_test_upload_if_one_file()
_test_public_read()
« no previous file with comments | « py/utils/gs_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698