Browse code

* run-tests.py: Updated paths for the new sync semantics. * s3cmd, S3/S3.py: Small fixes to make testsuite happy.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@349 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2009/01/22 07:14:17
Showing 4 changed files
... ...
@@ -1,3 +1,9 @@
1
+2009-01-22  Michal Ludvig  <michal@logix.cz>
2
+
3
+	* run-tests.py: Updated paths for the new sync
4
+	  semantics.
5
+	* s3cmd, S3/S3.py: Small fixes to make testsuite happy.
6
+
1 7
 2009-01-21  Michal Ludvig  <michal@logix.cz>
2 8
 
3 9
 	* s3cmd: Migrated 'sync' local->remote to the new
... ...
@@ -207,7 +207,7 @@ class S3(object):
207 207
 		if uri.type != "s3":
208 208
 			raise ValueError("Expected URI type 's3', got '%s'" % uri.type)
209 209
 		request = self.create_request("OBJECT_GET", uri = uri)
210
-		labels = { 'source' : uri, 'destination' : stream.name, 'extra' : extra_label }
210
+		labels = { 'source' : unicodise(uri.uri()), 'destination' : unicodise(stream.name), 'extra' : extra_label }
211 211
 		response = self.recv_file(request, stream, labels, start_position)
212 212
 		return response
213 213
 
... ...
@@ -153,6 +153,9 @@ def test_rmdir(label, dir_name):
153 153
 		cmd.append(dir_name)
154 154
 		return test(label, cmd)
155 155
 
156
+def test_flushdir(label, dir_name):
157
+	test_rmdir(label + "(rm)", dir_name)
158
+	return test_mkdir(label + "(mk)", dir_name)
156 159
 
157 160
 argv = sys.argv[1:]
158 161
 while argv:
... ...
@@ -208,19 +211,18 @@ test_s3cmd("Buckets list", ["ls"],
208 208
 
209 209
 
210 210
 ## ====== Sync to S3
211
-test_s3cmd("Sync to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ])
211
+test_s3cmd("Sync to S3", ['sync', 'testsuite/', 's3://s3cmd-autotest-1/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
212
+	must_not_find_re = [ "\.svn/", "\.png$" ])
212 213
 
213 214
 if have_encoding:
214 215
 	## ====== Sync UTF-8 / GBK / ... to S3
215
-	test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, enc_base_remote, '--exclude', '.svn/*', '--no-encrypt' ])
216
+	test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, 's3://s3cmd-autotest-1/xyz/encodings/', '--exclude', '.svn/*', '--no-encrypt' ],
217
+		must_find = [ u"File 'testsuite/encodings/%(encoding)s/%(pattern)s' stored as 's3://s3cmd-autotest-1/xyz/encodings/%(encoding)s/%(pattern)s'" % { 'encoding' : encoding, 'pattern' : enc_pattern } ])
216 218
 
217 219
 
218 220
 ## ====== List bucket content
219
-must_find_re = [ u"D s3://s3cmd-autotest-1/xyz/binary/$", u"D s3://s3cmd-autotest-1/xyz/etc/$" ]
221
+must_find_re = [ u"DIR   s3://s3cmd-autotest-1/xyz/binary/$", u"DIR   s3://s3cmd-autotest-1/xyz/etc/$" ]
220 222
 must_not_find = [ u"random-crap.md5", u".svn" ]
221
-if have_encoding:
222
-	must_find_re.append(u"D %s$" % enc_base_remote)
223
-	must_not_find.append(enc_pattern)
224 223
 test_s3cmd("List bucket content", ['ls', 's3://s3cmd-autotest-1/xyz/'],
225 224
 	must_find_re = must_find_re,
226 225
 	must_not_find = must_not_find)
... ...
@@ -229,7 +231,7 @@ test_s3cmd("List bucket content", ['ls', 's3://s3cmd-autotest-1/xyz/'],
229 229
 ## ====== List bucket recursive
230 230
 must_find = [ u"s3://s3cmd-autotest-1/xyz/binary/random-crap.md5" ]
231 231
 if have_encoding:
232
-	must_find.append(enc_base_remote + enc_pattern)
232
+	must_find.append(u"s3://s3cmd-autotest-1/xyz/encodings/%(encoding)s/%(pattern)s" % { 'encoding' : encoding, 'pattern' : enc_pattern })
233 233
 test_s3cmd("List bucket recursive", ['ls', '--recursive', 's3://s3cmd-autotest-1'],
234 234
 	must_find = must_find,
235 235
 	must_not_find = [ "logo.png" ])
... ...
@@ -238,21 +240,25 @@ test_s3cmd("List bucket recursive", ['ls', '--recursive', 's3://s3cmd-autotest-1
238 238
 # test_s3cmd("Recursive put", ['put', '--recursive', 'testsuite/etc', 's3://s3cmd-autotest-1/xyz/'])
239 239
 
240 240
 
241
-## ====== rmdir local
242
-test_rmdir("Removing local target", 'testsuite-out')
241
+## ====== Clean up local destination dir
242
+test_flushdir("Clean testsuite-out/", "testsuite-out")
243 243
 
244 244
 
245 245
 ## ====== Sync from S3
246
-must_find = [ "stored as testsuite-out/binary/random-crap.md5 " ]
246
+must_find = [ "File 's3://s3cmd-autotest-1/xyz/binary/random-crap.md5' stored as 'testsuite-out/xyz/binary/random-crap.md5'" ]
247 247
 if have_encoding:
248
-	must_find.append("stored as testsuite-out/" + encoding + "/" + enc_pattern)
248
+	must_find.append(u"File 's3://s3cmd-autotest-1/xyz/encodings/%(encoding)s/%(pattern)s' stored as 'testsuite-out/xyz/encodings/%(encoding)s/%(pattern)s' " % { 'encoding' : encoding, 'pattern' : enc_pattern })
249 249
 test_s3cmd("Sync from S3", ['sync', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'],
250 250
 	must_find = must_find)
251 251
 
252 252
 
253
+## ====== Clean up local destination dir
254
+test_flushdir("Clean testsuite-out/", "testsuite-out")
255
+
256
+
253 257
 ## ====== Put public, guess MIME
254 258
 test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public', 'testsuite/etc/logo.png', 's3://s3cmd-autotest-1/xyz/etc/logo.png'],
255
-	must_find = [ "stored as s3://s3cmd-autotest-1/xyz/etc/logo.png" ])
259
+	must_find = [ "stored as 's3://s3cmd-autotest-1/xyz/etc/logo.png'" ])
256 260
 
257 261
 
258 262
 ## ====== Retrieve from URL
... ...
@@ -285,7 +291,8 @@ if have_wget:
285 285
 
286 286
 
287 287
 ## ====== Sync more to S3
288
-test_s3cmd("Sync more to S3", ['sync', 'testsuite', 's3://s3cmd-autotest-1/xyz/', '--no-encrypt' ])
288
+test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://s3cmd-autotest-1/xyz/', '--no-encrypt' ],
289
+	must_find = [ "File 'testsuite/.svn/format' stored as 's3://s3cmd-autotest-1/xyz/.svn/format' " ])
289 290
 
290 291
 
291 292
 ## ====== Rename within S3
... ...
@@ -302,8 +309,9 @@ test_s3cmd("Rename (NoSuchKey)", ['mv', 's3://s3cmd-autotest-1/xyz/etc/logo.png'
302 302
 
303 303
 ## ====== Sync more from S3
304 304
 test_s3cmd("Sync more from S3", ['sync', '--delete-removed', 's3://s3cmd-autotest-1/xyz', 'testsuite-out'],
305
-	must_find = [ "deleted 'testsuite-out/logo.png'", "stored as testsuite-out/etc2/Logo.PNG (22059 bytes", 
306
-	              "stored as testsuite-out/.svn/format " ],
305
+	must_find = [ "deleted: testsuite-out/logo.png",
306
+	              "File 's3://s3cmd-autotest-1/xyz/etc2/Logo.PNG' stored as 'testsuite-out/xyz/etc2/Logo.PNG' (22059 bytes", 
307
+	              "File 's3://s3cmd-autotest-1/xyz/.svn/format' stored as 'testsuite-out/xyz/.svn/format' " ],
307 308
 	must_not_find_re = [ "not-deleted.*etc/logo.png" ])
308 309
 
309 310
 
... ...
@@ -118,8 +118,8 @@ def subcmd_bucket_list(s3, uri):
118 118
 			raise
119 119
 
120 120
 	for prefix in response['common_prefixes']:
121
-		output(u"%s %s" % (
122
-			"D".rjust(28),
121
+		output(u"%s   %s" % (
122
+			"DIR".rjust(26),
123 123
 			uri.compose_uri(bucket, prefix["Prefix"])))
124 124
 
125 125
 	for object in response["list"]:
... ...
@@ -308,7 +308,7 @@ def cmd_object_put(args):
308 308
 			continue
309 309
 		speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
310 310
 		if not Config().progress_meter:
311
-			output(u"File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
311
+			output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
312 312
 				(unicodise(full_name_orig), uri_final, response["size"], response["elapsed"], 
313 313
 				speed_fmt[0], speed_fmt[1], seq_label))
314 314
 		if Config().acl_public:
... ...
@@ -772,7 +772,7 @@ def cmd_sync_remote2local(args):
772 772
 				open_flags |= os.O_TRUNC
773 773
 				# open_flags |= os.O_EXCL
774 774
 
775
-				debug(u"dst_file=%s" % dst_file)
775
+				debug(u"dst_file=%s" % unicodise(dst_file))
776 776
 				# This will have failed should the file exist
777 777
 				os.close(os.open(dst_file, open_flags))
778 778
 				# Yeah I know there is a race condition here. Sadly I don't know how to open() in exclusive mode.
... ...
@@ -818,8 +818,8 @@ def cmd_sync_remote2local(args):
818 818
 			continue
819 819
 		speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
820 820
 		if not Config().progress_meter:
821
-			output(u"File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
822
-				(uri, dst_file, response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
821
+			output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
822
+				(uri, unicodise(dst_file), response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
823 823
 				seq_label))
824 824
 		total_size += response["size"]
825 825
 
... ...
@@ -939,7 +939,7 @@ def cmd_sync_local2remote(args):
939 939
 			continue
940 940
 		speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
941 941
 		if not cfg.progress_meter:
942
-			output(u"File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
942
+			output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
943 943
 				(item['full_name_unicode'], uri, response["size"], response["elapsed"], 
944 944
 				speed_fmt[0], speed_fmt[1], seq_label))
945 945
 		total_size += response["size"]
... ...
@@ -977,7 +977,7 @@ def cmd_setacl(args):
977 977
 	for key in remote_list:
978 978
 		seq += 1
979 979
 		seq_label = "[%d of %d]" % (seq, remote_count)
980
-		uri = key['remote_uri']
980
+		uri = S3Uri(remote_list[key]['object_uri_str'])
981 981
 		acl = s3.get_acl(uri)
982 982
 		debug(u"acl: %s - %r" % (uri, acl.grantees))
983 983
 		if cfg.acl_public: