]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add unit test for join twice failure
authorDavid Stainton <dstainton415@gmail.com>
Thu, 3 Dec 2015 02:44:54 +0000 (04:44 +0200)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 28 Dec 2015 15:32:37 +0000 (15:32 +0000)
src/allmydata/test/test_cli_magic_folder.py

index c69ee1e0050014a2e363b63bb97f9b6361c48b8b..5ea214cba7b35350c3b031fd19131d55b8b1b36d 100644 (file)
@@ -243,3 +243,30 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
             self.failUnlessIn("cannot start with '-'", str(e))
         else:
             self.fail("expected UsageError")
+
+    def test_join_twice_failure(self):
+        self.basedir = "cli/MagicFolder/create-join-twice-failure"
+        os.makedirs(self.basedir)
+        self.set_up_grid()
+        local_dir = os.path.join(self.basedir, "magic")
+        abs_local_dir_u = abspath_expanduser_unicode(unicode(local_dir), long_path=False)
+
+        d = self.do_create_magic_folder(0)
+        d.addCallback(lambda ign: self.do_invite(0, u"Alice"))
+        def get_invite_code_and_join((rc, stdout, stderr)):
+            self.invite_code = stdout.strip()
+            return self.do_join(0, unicode(local_dir), self.invite_code)
+        d.addCallback(get_invite_code_and_join)
+        def get_caps(ign):
+            self.collective_dircap, self.upload_dircap = self.get_caps_from_files(0)
+        d.addCallback(get_caps)
+        d.addCallback(lambda ign: self.check_joined_config(0, self.upload_dircap))
+        d.addCallback(lambda ign: self.check_config(0, abs_local_dir_u))
+        def join_again(ignore):
+            return self.do_cli("magic-folder", "join", self.invite_code, local_dir, client_num=0)
+        d.addCallback(join_again)
+        def get_results(result):
+            code = result[0]
+            self.failIfEqual(code, 0)
+        d.addCallback(get_results)
+        return d