]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add complete usage functionality to create
authorDavid Stainton <dstainton415@gmail.com>
Tue, 23 Jun 2015 09:19:45 +0000 (02:19 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 1 Oct 2015 00:19:44 +0000 (01:19 +0100)
src/allmydata/scripts/magic_folder_cli.py
src/allmydata/test/test_cli_magic_folder.py

index 58f13e152f8779246c594a3dfa001406ca58def9..08af3e2588f44a9fb297ff3f4cb5d975bd6ca132 100644 (file)
@@ -29,6 +29,34 @@ class CreateOptions(BasedirOptions):
 def create(options):
     from allmydata.scripts import tahoe_add_alias
     rc = tahoe_add_alias.create_alias(options)
+
+    if options.nickname is not None:
+        invite_options = InviteOptions()
+        invite_options.aliases = get_aliases(options['node-directory'])
+        invite_options["node-url"] = options["node-url"]
+        invite_options["node-directory"] = options["node-directory"]
+        invite_options.alias = options.alias
+        invite_options.nickname = options.nickname
+        invite_options.stdin = StringIO("")
+        invite_options.stdout = StringIO()
+        invite_options.strerr = StringIO()
+        rc = invite(invite_options)
+        if rc != 0:
+            print >>options.stderr, "magic-folder: failed to invite after create\n"
+            return -1
+        invite_code = invite_options.stdout.getvalue().strip()
+
+        join_options = JoinOptions()
+        join_options.alias = options.alias
+        join_options.aliases = get_aliases(options['node-directory'])
+        join_options["node-url"] = options["node-url"]
+        join_options["node-directory"] = options["node-directory"]
+        join_options.invite_code = invite_code
+        join_options.local_dir = options.localdir
+        rc = join(join_options)
+        if rc != 0:
+            print >>options.stderr, "magic-folder: failed to invite after create\n"
+            return -1
     return rc
 
 def diminish_readonly(write_cap, node_url):
index c65a93b69a8d7f4412be04d65690f4de02b6ca61..b8418ac7f020f7bb8806909c31ee0e6fab9ceaa0 100644 (file)
@@ -33,10 +33,17 @@ class CreateMagicFolder(GridTestMixin, CLITestMixin, unittest.TestCase):
         d = self.do_cli("magic-folder", "join", invite_code, u"LOCAL_DIR")
         return d
 
-    def test_create_invite_join(self):
-        self.basedir = "cli/MagicFolder/create-invite-join"
+    def test_create_and_then_invite_join(self):
+        self.basedir = "cli/MagicFolder/create-and-then-invite-join"
         self.set_up_grid()
         d = self._create_magic_folder()
         d.addCallback(self._invite)
         d.addCallback(self._join)
         return d
+
+    def test_create_invite_join(self):
+        self.basedir = "cli/MagicFolder/create-invite-join"
+        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)
+        return d