Attempt to fix cli tests
This commit is contained in:
parent
b032ab829f
commit
2e587937c1
|
@ -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")
|
||||||
|
@ -58,7 +58,6 @@ def create(options):
|
||||||
print >>options.stderr, invite_options.stderr.getvalue()
|
print >>options.stderr, invite_options.stderr.getvalue()
|
||||||
return rc
|
return rc
|
||||||
invite_code = invite_options.stdout.getvalue().strip()
|
invite_code = invite_options.stdout.getvalue().strip()
|
||||||
|
|
||||||
join_options = _delegate_options(options, JoinOptions())
|
join_options = _delegate_options(options, JoinOptions())
|
||||||
join_options.invite_code = invite_code
|
join_options.invite_code = invite_code
|
||||||
fields = invite_code.split(INVITE_SEPARATOR)
|
fields = invite_code.split(INVITE_SEPARATOR)
|
||||||
|
@ -122,13 +121,15 @@ class JoinOptions(BasedirOptions):
|
||||||
synopsis = "INVITE_CODE LOCAL_DIR"
|
synopsis = "INVITE_CODE LOCAL_DIR"
|
||||||
dmd_write_cap = ""
|
dmd_write_cap = ""
|
||||||
magic_readonly_cap = ""
|
magic_readonly_cap = ""
|
||||||
def parseArgs(self, invite_code, local_dir):
|
def parseInvite(self, invite_code, local_dir):
|
||||||
BasedirOptions.parseArgs(self)
|
|
||||||
self.local_dir = argv_to_abspath(str(local_dir))
|
self.local_dir = argv_to_abspath(str(local_dir))
|
||||||
fields = invite_code.split(INVITE_SEPARATOR)
|
fields = invite_code.split(INVITE_SEPARATOR)
|
||||||
if len(fields) != 2:
|
if len(fields) != 2:
|
||||||
raise usage.UsageError("Invalid invite code.")
|
raise usage.UsageError("Invalid invite code.")
|
||||||
self.magic_readonly_cap, self.dmd_write_cap = fields
|
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):
|
def join(options):
|
||||||
dmd_cap_file = os.path.join(options["node-directory"], "private/magic_folder_dircap")
|
dmd_cap_file = os.path.join(options["node-directory"], "private/magic_folder_dircap")
|
||||||
|
|
|
@ -219,22 +219,29 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def test_create_invite_join_failure(self):
|
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 = magic_folder_cli.CreateOptions()
|
||||||
o.parent = magic_folder_cli.MagicFolderCommand()
|
o.parent = magic_folder_cli.MagicFolderCommand()
|
||||||
o.parent.parseOptions(["magic-folder"])
|
o.parent['node-directory'] = str(self.get_clientdir(i=0))
|
||||||
try:
|
try:
|
||||||
o.parseOptions(["magic:", "Alice", "-foo"])
|
o.parseArgs("magic:", "Alice", "-foo")
|
||||||
except usage.UsageError as e:
|
except usage.UsageError as e:
|
||||||
self.failUnlessIn("cannot start with '-'", str(e))
|
self.failUnlessIn("cannot start with '-'", str(e))
|
||||||
else:
|
else:
|
||||||
self.fail("expected UsageError")
|
self.fail("expected UsageError")
|
||||||
|
|
||||||
def test_join_failure(self):
|
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 = magic_folder_cli.JoinOptions()
|
||||||
o.parent = magic_folder_cli.MagicFolderCommand()
|
o.parent = magic_folder_cli.MagicFolderCommand()
|
||||||
o.parent.parseOptions(["magic-folder"])
|
o.parent['node-directory'] = str(self.get_clientdir(i=0))
|
||||||
try:
|
try:
|
||||||
o.parseOptions(["URI:invite+URI:code", "-foo"])
|
o.parseArgs("URI:invite+URI:code", "-foo")
|
||||||
except usage.UsageError as e:
|
except usage.UsageError as e:
|
||||||
self.failUnlessIn("cannot start with '-'", str(e))
|
self.failUnlessIn("cannot start with '-'", str(e))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue