Teach magic-folder join to use argv_to_abspath
- also we modify argv_to_abspath to through a usage error if the name starts with a '-' - add a test currently the tests fail
This commit is contained in:
parent
f28a161f11
commit
7025dd6a26
|
@ -22,7 +22,7 @@ class CreateOptions(BasedirOptions):
|
||||||
raise usage.UsageError("An alias must end with a ':' character.")
|
raise usage.UsageError("An alias must end with a ':' character.")
|
||||||
self.alias = alias[:-1]
|
self.alias = alias[:-1]
|
||||||
self.nickname = nickname
|
self.nickname = nickname
|
||||||
self.localdir = localdir
|
self.localdir = argv_to_abspath(str(localdir))
|
||||||
if self.nickname and not self.localdir:
|
if self.nickname and not self.localdir:
|
||||||
raise usage.UsageError("If NICKNAME is specified then LOCALDIR must also be specified.")
|
raise usage.UsageError("If NICKNAME is specified then LOCALDIR must also be specified.")
|
||||||
node_url_file = os.path.join(self['node-directory'], "node.url")
|
node_url_file = os.path.join(self['node-directory'], "node.url")
|
||||||
|
|
|
@ -215,3 +215,18 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||||
d.addCallback(lambda x: self.check_joined_config(0, self.upload_dircap))
|
d.addCallback(lambda x: self.check_joined_config(0, self.upload_dircap))
|
||||||
d.addCallback(lambda x: self.check_config(0, self.local_dir))
|
d.addCallback(lambda x: self.check_config(0, self.local_dir))
|
||||||
return d
|
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")
|
||||||
|
self.local_dir = "-" + self.local_dir
|
||||||
|
d = self.do_cli("magic-folder", "create", u"magic:", u"Alice", self.local_dir)
|
||||||
|
def _done((rc,stdout,stderr)):
|
||||||
|
print "rc %s" % (rc,)
|
||||||
|
print "stdout %s" % (stdout,)
|
||||||
|
print "stderr %s" % (stderr,)
|
||||||
|
self.failUnless(rc == 1)
|
||||||
|
return (rc,stdout,stderr)
|
||||||
|
d.addCallback(_done)
|
||||||
|
return d
|
||||||
|
|
|
@ -95,6 +95,8 @@ def argv_to_unicode(s):
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
raise usage.UsageError("Argument %s cannot be decoded as %s." %
|
raise usage.UsageError("Argument %s cannot be decoded as %s." %
|
||||||
(quote_output(s), io_encoding))
|
(quote_output(s), io_encoding))
|
||||||
|
if local_dir.startswith('-'):
|
||||||
|
raise usage.UsageError("Argument %s cannot start with a -." % (quote_output(s),))
|
||||||
|
|
||||||
def argv_to_abspath(s, **kwargs):
|
def argv_to_abspath(s, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue