]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Adds test_cli.Cp.test_cp_copies_dir
authorMark Berger <mark.berger.j@gmail.com>
Mon, 5 Aug 2013 13:05:05 +0000 (09:05 -0400)
committerBrian Warner <warner@lothar.com>
Tue, 2 Sep 2014 19:51:13 +0000 (12:51 -0700)
src/allmydata/test/test_cli.py

index 7039ebb8744c31c0e1e01a805f71ae9d6ea42af0..473b6aee695227f863f11a55e4070888ad73a380 100644 (file)
@@ -2473,6 +2473,40 @@ starting copy, 2 files, 1 directories
         d.addCallback(_check)
         return d
 
+    def test_cp_copies_dir(self):
+        # This test ensures that a directory is copied using
+        # tahoe cp -r. Refer to ticket #712:
+        # https://tahoe-lafs.org/trac/tahoe-lafs/ticket/712
+
+        self.basedir = "cli/Cp/cp_copies_dir"
+        self.set_up_grid()
+        subdir = os.path.join(self.basedir, "foo")
+        os.mkdir(subdir)
+        test1_path = os.path.join(subdir, "test1")
+        fileutil.write(test1_path, "test1")
+
+        d = self.do_cli("create-alias", "tahoe")
+        d.addCallback(lambda ign:
+            self.do_cli("cp", "-r", subdir, "tahoe:"))
+        d.addCallback(lambda ign:
+            self.do_cli("ls", "tahoe:"))
+        def _check(res, item):
+            (rc, out, err) = res
+            self.failUnlessEqual(rc, 0)
+            self.failUnlessEqual(err, "")
+            self.failUnlessIn(item, out, str(res))
+        d.addCallback(_check, "foo")
+        d.addCallback(lambda ign:
+            self.do_cli("ls", "tahoe:foo/"))
+        d.addCallback(_check, "test1")
+
+        d.addCallback(lambda ign: fileutil.rm_dir(subdir))
+        d.addCallback(lambda ign: self.do_cli("cp", "-r", "tahoe:foo", self.basedir))
+        def _check_local_fs(ign):
+            self.failUnless(os.path.isdir(self.basedir))
+            self.failUnless(os.path.isfile(test1_path))
+        d.addCallback(_check_local_fs)
+        return d
 
 class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):