From: David Stainton Date: Tue, 23 Jun 2015 21:00:22 +0000 (-0700) Subject: Test return vals and fix join return val X-Git-Url: https://git.rkrishnan.org/simplejson?a=commitdiff_plain;h=9076914f27fec1312f4432446517aead80b4eb73;p=tahoe-lafs%2Ftahoe-lafs.git Test return vals and fix join return val --- diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py index 127e431b..09fbc688 100644 --- a/src/allmydata/scripts/magic_folder_cli.py +++ b/src/allmydata/scripts/magic_folder_cli.py @@ -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 = [ diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index 77df1c1a..3dab5652 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -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