Index: py/utils/gs_utils_manualtest.py |
diff --git a/py/utils/gs_utils_manualtest.py b/py/utils/gs_utils_manualtest.py |
index a5258d0c322d7a5b283c7cbcc3262643f06d8ef0..b4f70a6cc3b5b7f85f00680882ec461ba0c27d88 100755 |
--- a/py/utils/gs_utils_manualtest.py |
+++ b/py/utils/gs_utils_manualtest.py |
@@ -45,8 +45,8 @@ def _test_public_read(): |
gs.list_bucket_contents(bucket=TEST_BUCKET, subdir=None) |
-def _test_only_if_modified(): |
- """Test only_if_modified param within upload_file().""" |
+def _test_upload_if(): |
+ """Test upload_if param within upload_file().""" |
gs = _get_authenticated_gs_handle() |
filename = 'filename' |
remote_dir = _get_unique_posix_dir() |
@@ -58,39 +58,50 @@ def _test_only_if_modified(): |
with open(local_path, 'w') as f: |
f.write('original contents') |
gs.upload_file(source_path=local_path, dest_bucket=TEST_BUCKET, |
- dest_path=dest_path, only_if_modified=True) |
+ dest_path=dest_path, upload_if=gs.UploadIf.IF_NEW) |
try: |
- # Re-upload the same file one second later, with only_if_modified=False; |
+ # Re-upload the same file, with upload_if=gs.UploadIf.ALWAYS; |
# the timestamp should change. |
old_timestamp = gs.get_last_modified_time( |
bucket=TEST_BUCKET, path=dest_path) |
time.sleep(2) |
gs.upload_file(source_path=local_path, dest_bucket=TEST_BUCKET, |
- dest_path=dest_path, only_if_modified=False) |
+ dest_path=dest_path, upload_if=gs.UploadIf.ALWAYS) |
new_timestamp = gs.get_last_modified_time( |
bucket=TEST_BUCKET, path=dest_path) |
assert old_timestamp != new_timestamp, '%s != %s' % ( |
old_timestamp, new_timestamp) |
- # Re-upload the same file one second later, with only_if_modified=True; |
+ # Re-upload the same file, with upload_if=gs.UploadIf.IF_MODIFIED; |
# the timestamp should NOT change. |
old_timestamp = new_timestamp |
time.sleep(2) |
gs.upload_file(source_path=local_path, dest_bucket=TEST_BUCKET, |
- dest_path=dest_path, only_if_modified=True) |
+ dest_path=dest_path, upload_if=gs.UploadIf.IF_MODIFIED) |
new_timestamp = gs.get_last_modified_time( |
bucket=TEST_BUCKET, path=dest_path) |
assert old_timestamp == new_timestamp, '%s == %s' % ( |
old_timestamp, new_timestamp) |
- # MODIFY and re-upload the file one second later, with |
- # only_if_modified=True; the timestamp SHOULD change. |
+ # Modify and re-upload the file, with upload_if=gs.UploadIf.IF_NEW; |
+ # the timestamp should still not change. |
old_timestamp = new_timestamp |
with open(local_path, 'w') as f: |
f.write('modified contents') |
time.sleep(2) |
gs.upload_file(source_path=local_path, dest_bucket=TEST_BUCKET, |
- dest_path=dest_path, only_if_modified=True) |
+ dest_path=dest_path, upload_if=gs.UploadIf.IF_NEW) |
+ new_timestamp = gs.get_last_modified_time( |
+ bucket=TEST_BUCKET, path=dest_path) |
+ assert old_timestamp == new_timestamp, '%s == %s' % ( |
+ old_timestamp, new_timestamp) |
+ |
+ # Re-upload the modified file, with upload_if=gs.UploadIf.IF_MODIFIED; |
+ # now the timestamp SHOULD change. |
+ old_timestamp = new_timestamp |
+ time.sleep(2) |
+ gs.upload_file(source_path=local_path, dest_bucket=TEST_BUCKET, |
+ dest_path=dest_path, upload_if=gs.UploadIf.IF_MODIFIED) |
new_timestamp = gs.get_last_modified_time( |
bucket=TEST_BUCKET, path=dest_path) |
assert old_timestamp != new_timestamp, '%s != %s' % ( |
@@ -264,7 +275,7 @@ def _test_dir_upload_and_download(): |
if __name__ == '__main__': |
- _test_only_if_modified() |
+ _test_upload_if() |
_test_public_read() |
_test_authenticated_round_trip() |
_test_dir_upload_and_download() |