]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Attempt to fix cli tests
authorDavid Stainton <dstainton415@gmail.com>
Tue, 20 Oct 2015 11:08:14 +0000 (13:08 +0200)
committermeejah <meejah@meejah.ca>
Wed, 20 Jan 2016 08:30:15 +0000 (01:30 -0700)
src/allmydata/scripts/magic_folder_cli.py
src/allmydata/test/test_cli_magic_folder.py

index 5356ce8b35a36bf33e7652af54c79f0e4e7f48df..a82e677b5ef35a7bcbc974e362554b4c85f7beeb 100644 (file)
@@ -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")
index 9bc08bdcaed2a4be516b83c743d267d94220baac..d424d752b837574c86cb664853b03873589c1b0f 100644 (file)
@@ -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: