]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix options passed to mkdir from magic invite
authorDavid Stainton <dstainton415@gmail.com>
Mon, 22 Jun 2015 22:09:57 +0000 (15:09 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:44 +0000 (01:19 +0100)
- here we also clean up the magic folder cli unit tests

src/allmydata/scripts/magic_folder_cli.py
src/allmydata/test/test_cli_magic_folder.py

index 993c1c4a49dbe71b75087ccac5705075a1392808..efc5e0b46f4aa6e2867ef103c04fd050c21a3907 100644 (file)
@@ -1,11 +1,13 @@
 
 import os
-
+from cStringIO import StringIO
 from twisted.python import usage, failure
+
 from allmydata.scripts.common import BaseOptions
 from .common import BaseOptions, BasedirOptions, get_aliases
 from .cli import MakeDirectoryOptions
 
+
 class CreateOptions(BasedirOptions):
     nickname = None
     localdir = None
@@ -28,29 +30,31 @@ def create(options):
 class InviteOptions(BasedirOptions):
     nickname = None
     synopsis = "MAGIC_ALIAS: NICKNAME"
+    stdin = StringIO("")
     def parseArgs(self, alias, nickname=None):
         BasedirOptions.parseArgs(self)
-        print "InviteOptions parseArgs() alias %s nickname %s" % (alias, nickname,)
         self.alias = alias
         self.nickname = nickname
         node_url_file = os.path.join(self['node-directory'], "node.url")
         self['node-url'] = open(node_url_file, "r").read().strip()
-
         aliases = get_aliases(self['node-directory'])
-        print "ALIASES %s" % (aliases,)
         self.aliases = aliases
 
 def invite(options):
     from allmydata.scripts import tahoe_mkdir
-    mkdirOptions = MakeDirectoryOptions()
-    mkdirOptions.where = options.nickname
-    mkdirOptions.stdout = options.stdout
-    mkdirOptions.stdin = options.stdin
-    mkdirOptions.stderr = options.stderr
-    mkdirOptions['node-url'] = options['node-url']
-    mkdirOptions.aliases = options.aliases
-    mkdirOptions['node-directory'] = options['node-directory']
-    rc = tahoe_mkdir.mkdir(mkdirOptions)
+    mkdir_options = MakeDirectoryOptions()
+    mkdir_options.where = "%s:%s" % (options.alias, options.nickname)
+    mkdir_options.stdout = options.stdout
+    mkdir_options.stdin = options.stdin
+    mkdir_options.stderr = options.stderr
+    mkdir_options['node-url'] = options['node-url']
+    mkdir_options.aliases = options.aliases
+    mkdir_options['node-directory'] = options['node-directory']
+    rc = tahoe_mkdir.mkdir(mkdir_options)
+    if rc != 0:
+        return rc
+    write_capability = mkdir_options.stdout.getvalue().strip()
+    print "\nNEW write cap %s" % (write_capability,)
     return rc
 
 class JoinOptions(BasedirOptions):
index c6df73f5dd0247c4b0e105e25576bb1e7ad39a41..684e1c914bf96e9f8b5c547f0c09f3efb8392e6c 100644 (file)
@@ -14,27 +14,22 @@ from .test_cli import CLITestMixin
 class CreateMagicFolder(GridTestMixin, CLITestMixin, unittest.TestCase):
 
     def _create_magic_folder(self):
-        d = self.do_cli("magic-folder", "create", "my_magic_folder")
+        d = self.do_cli("magic-folder", "create", "magic")
         def _done((rc,stdout,stderr)):
-            self.failUnless("Alias 'my_magic_folder' created" in stdout)
+            self.failUnless("Alias 'magic' created" in stdout)
             self.failIf(stderr)
             aliases = get_aliases(self.get_clientdir())
-            self.failUnless("my_magic_folder" in aliases)
-            self.failUnless(aliases["my_magic_folder"].startswith("URI:DIR2:"))
+            self.failUnless("magic" in aliases)
+            self.failUnless(aliases["magic"].startswith("URI:DIR2:"))
         d.addCallback(_done)
         return d
 
-    def test_create(self):
-        self.basedir = "cli/MagicFolder/create"
-        self.set_up_grid()
-        return self._create_magic_folder()
-
     def _invite(self, ignore):
-        d = self.do_cli("magic-folder", "invite", "magicFolder1", "Nicki")
+        d = self.do_cli("magic-folder", "invite", "magic", u"Alice:")
         return d
 
-    def test_invite(self):
-        self.basedir = "cli/MagicFolder/invite"
+    def test_create_invite_join(self):
+        self.basedir = "cli/MagicFolder/create-invite-join"
         self.set_up_grid()
         d = self._create_magic_folder()
         d.addCallback(self._invite)