Add complete usage functionality to create

This commit is contained in:
David Stainton 2015-06-23 02:19:45 -07:00 committed by Daira Hopwood
parent 9deae9b587
commit 1e710187c4
2 changed files with 37 additions and 2 deletions

View 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):

View 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