]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Test return vals and fix join return val
authorDavid Stainton <dstainton415@gmail.com>
Tue, 23 Jun 2015 21:00:22 +0000 (14:00 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 16:55:59 +0000 (17:55 +0100)
src/allmydata/scripts/magic_folder_cli.py
src/allmydata/test/test_cli_magic_folder.py

index 127e431b44c2d8b283e1b24dbc3911764a3cdb16..09fbc688e5ccfbdacadc441dd6edd91ff2363839 100644 (file)
@@ -148,18 +148,15 @@ class JoinOptions(BasedirOptions):
 def join(options):
     fields = options.invite_code.split(INVITE_SEPERATOR)
     assert len(fields) == 2
-    magic_readonly_cap, dmd_write_cap = fields
 
+    magic_readonly_cap, dmd_write_cap = fields
     dmd_cap_file = os.path.join(options["node-directory"], "private/magic_folder_dircap")
-    fileutil.write(dmd_cap_file, dmd_write_cap)
-
     collective_readcap_file = os.path.join(options["node-directory"], "private/collective_dircap")
-    fileutil.write(collective_readcap_file, magic_readonly_cap)
-
-    c = open(os.path.join(options["node-directory"], "tahoe.cfg"), "a")
-    c.write("[magic_folder]\nenabled = True\nlocal.directory = %s\n" % (options.local_dir,))
-    c.close()
 
+    fileutil.write(dmd_cap_file, dmd_write_cap)
+    fileutil.write(collective_readcap_file, magic_readonly_cap)
+    fileutil.write(os.path.join(options["node-directory"], "tahoe.cfg"), "[magic_folder]\nenabled = True\nlocal.directory = %s\n" % (options.local_dir,))
+    return 0
 
 class MagicFolderCommand(BaseOptions):
     subCommands = [
index 77df1c1a9178ce0dced5d311360c4087d7176b5d..3dab565258f09e5ba2b859fdbe19b889683fa6f2 100644 (file)
@@ -17,6 +17,7 @@ class CreateMagicFolder(GridTestMixin, CLITestMixin, unittest.TestCase):
     def _create_magic_folder(self):
         d = self.do_cli("magic-folder", "create", "magic")
         def _done((rc,stdout,stderr)):
+            self.failUnless(rc == 0)
             self.failUnless("Alias 'magic' created" in stdout)
             self.failIf(stderr)
             aliases = get_aliases(self.get_clientdir())
@@ -27,11 +28,20 @@ class CreateMagicFolder(GridTestMixin, CLITestMixin, unittest.TestCase):
 
     def _invite(self, ignore):
         d = self.do_cli("magic-folder", "invite", u"magic", u"Alice")
+        def _done((rc,stdout,stderr)):
+            self.failUnless(rc == 0)
+            return (rc,stdout,stderr)
+        d.addCallback(_done)
         return d
 
     def _join(self, result):
         invite_code = result[1].strip()
         d = self.do_cli("magic-folder", "join", invite_code, u"Alice_local_magic")
+        def _done((rc,stdout,stderr)):
+            print "_join rc %s" % (rc,)
+            self.failUnless(rc == 0)
+            return (rc,stdout,stderr)
+        d.addCallback(_done)
         return d
 
     def _check_config(self, result):
@@ -53,4 +63,8 @@ class CreateMagicFolder(GridTestMixin, CLITestMixin, unittest.TestCase):
         self.set_up_grid()
         magic_local_dir = os.path.join(self.basedir, "magic")
         d = self.do_cli("magic-folder", "create", u"magic", u"Alice", magic_local_dir)
+        def _done((rc,stdout,stderr)):
+            self.failUnless(rc == 0)
+            return (rc,stdout,stderr)
+        d.addCallback(_done)
         return d