Chromium Code Reviews| 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..773071eaaadbf26bc2e9444e4e51fb33ba64b7f7 100755 |
| --- a/py/utils/gs_utils_manualtest.py |
| +++ b/py/utils/gs_utils_manualtest.py |
| @@ -39,6 +39,36 @@ 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/path1', 'bucket', 'path1'), |
|
rmistry
2014/07/29 20:36:20
Could you also please add gs://bucket/path1/ and m
epoger
2014/07/30 01:10:49
Done.
|
| + ('gs://bucket/path1/path2', 'bucket', 'path1/path2'), |
|
rmistry
2014/07/29 20:36:20
Optional Nit: Instead of aligning some of these le
epoger
2014/07/30 01:10:49
Yeah, that makes sense, and the style guide agrees
|
| + ] |
| + 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 +385,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() |