From: David Stainton Date: Tue, 20 Oct 2015 11:08:14 +0000 (+0200) Subject: Attempt to fix cli tests X-Git-Url: https://git.rkrishnan.org/frontends/simplejson/%3C?a=commitdiff_plain;h=8ad6e30c9239d1b02576b95f517d3984eb4b1661;p=tahoe-lafs%2Ftahoe-lafs.git Attempt to fix cli tests --- diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py index 5356ce8b..a82e677b 100644 --- a/src/allmydata/scripts/magic_folder_cli.py +++ b/src/allmydata/scripts/magic_folder_cli.py @@ -22,7 +22,7 @@ class CreateOptions(BasedirOptions): raise usage.UsageError("An alias must end with a ':' character.") self.alias = alias[:-1] self.nickname = nickname - self.localdir = localdir + self.localdir = argv_to_abspath(str(localdir)) if self.nickname and not self.localdir: raise usage.UsageError("If NICKNAME is specified then LOCALDIR must also be specified.") node_url_file = os.path.join(self['node-directory'], "node.url") @@ -58,7 +58,6 @@ def create(options): print >>options.stderr, invite_options.stderr.getvalue() return rc invite_code = invite_options.stdout.getvalue().strip() - join_options = _delegate_options(options, JoinOptions()) join_options.invite_code = invite_code fields = invite_code.split(INVITE_SEPARATOR) @@ -122,13 +121,15 @@ class JoinOptions(BasedirOptions): synopsis = "INVITE_CODE LOCAL_DIR" dmd_write_cap = "" magic_readonly_cap = "" - def parseArgs(self, invite_code, local_dir): - BasedirOptions.parseArgs(self) + def parseInvite(self, invite_code, local_dir): self.local_dir = argv_to_abspath(str(local_dir)) fields = invite_code.split(INVITE_SEPARATOR) if len(fields) != 2: raise usage.UsageError("Invalid invite code.") self.magic_readonly_cap, self.dmd_write_cap = fields + def parseArgs(self, invite_code, local_dir): + BasedirOptions.parseArgs(self) + self.parseInvite(invite_code, local_dir) def join(options): dmd_cap_file = os.path.join(options["node-directory"], "private/magic_folder_dircap") diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index 9bc08bdc..d424d752 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -219,22 +219,29 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase): return d def test_create_invite_join_failure(self): + self.basedir = "cli/MagicFolder/create-invite-join-failure" + self.set_up_grid() + self.local_dir = os.path.join(self.basedir, "magic") o = magic_folder_cli.CreateOptions() o.parent = magic_folder_cli.MagicFolderCommand() - o.parent.parseOptions(["magic-folder"]) + o.parent['node-directory'] = str(self.get_clientdir(i=0)) try: - o.parseOptions(["magic:", "Alice", "-foo"]) + o.parseArgs("magic:", "Alice", "-foo") except usage.UsageError as e: self.failUnlessIn("cannot start with '-'", str(e)) else: self.fail("expected UsageError") def test_join_failure(self): + self.basedir = "cli/MagicFolder/create-join-failure" + self.set_up_grid() + self.local_dir = os.path.join(self.basedir, "magic") + o = magic_folder_cli.JoinOptions() o.parent = magic_folder_cli.MagicFolderCommand() - o.parent.parseOptions(["magic-folder"]) + o.parent['node-directory'] = str(self.get_clientdir(i=0)) try: - o.parseOptions(["URI:invite+URI:code", "-foo"]) + o.parseArgs("URI:invite+URI:code", "-foo") except usage.UsageError as e: self.failUnlessIn("cannot start with '-'", str(e)) else: