]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Refactor test_move_tree and make directory names non-ASCII.
authorDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 12:42:29 +0000 (13:42 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 18:50:15 +0000 (19:50 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/test_drop_upload.py

index 691304a73fdb1efdd19667bc30efe4f9295798f7..b2eb1e48f30c2c6ea38f94711d57d06f327eb0fd 100644 (file)
@@ -128,20 +128,25 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         self.client = self.g.clients[0]
         self.stats_provider = self.client.stats_provider
 
+        empty_tree_name = u"empty_tr\u00EAe"
+        empty_tree_dir = abspath_expanduser_unicode(empty_tree_name, base=self.basedir)
+        new_empty_tree_dir = abspath_expanduser_unicode(empty_tree_name, base=self.local_dir)
+
+        small_tree_name = u"small_tr\u00EAe"
+        small_tree_dir = abspath_expanduser_unicode(small_tree_name, base=self.basedir)
+        new_small_tree_dir = abspath_expanduser_unicode(small_tree_name, base=self.local_dir)
+
         d = self.client.create_dirnode()
         d.addCallback(self._made_upload_dir)
 
         d.addCallback(self._create_uploader)
 
         def testMoveEmptyTree(res):
-            tree_name = u'empty_tree'
-            tree_dir = abspath_expanduser_unicode(tree_name, base=self.basedir)
-            self.mkdir_nonascii(tree_dir)
+            self.mkdir_nonascii(empty_tree_dir)
             d2 = defer.Deferred()
             self.uploader.set_uploaded_callback(d2.callback, ignore_count=0)
-            new_tree_dir = abspath_expanduser_unicode(tree_name, base=self.local_dir)
-            os.rename(tree_dir, new_tree_dir)
-            self.notify_close_write(to_filepath(new_tree_dir))
+            os.rename(empty_tree_dir, new_empty_tree_dir)
+            self.notify_close_write(to_filepath(new_empty_tree_dir))
             return d2
         d.addCallback(testMoveEmptyTree)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 1))
@@ -150,15 +155,12 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.directories_created'), 1))
 
         def testMoveSmallTree(res):
-            tree_name = u'small_tree'
-            tree_dir = abspath_expanduser_unicode(tree_name, base=self.basedir)
-            os.mkdir(tree_dir)
-            fileutil.write(abspath_expanduser_unicode(u"what", base=tree_dir), "say when")
+            self.mkdir_nonascii(small_tree_dir)
+            fileutil.write(abspath_expanduser_unicode(u"what", base=small_tree_dir), "say when")
             d2 = defer.Deferred()
             self.uploader.set_uploaded_callback(d2.callback, ignore_count=1)
-            new_tree_dir = abspath_expanduser_unicode(tree_name, base=self.local_dir)
-            os.rename(tree_dir, new_tree_dir)
-            self.notify_close_write(to_filepath(new_tree_dir))
+            os.rename(small_tree_dir, new_small_tree_dir)
+            self.notify_close_write(to_filepath(new_small_tree_dir))
             return d2
         d.addCallback(testMoveSmallTree)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 3))