return o
class CLITestMixin(ReallyEqualMixin):
- def do_cli_n(self, client_num, verb, *args, **kwargs):
- """
- do_cli_n is used to execute client CLI commands when there is more
- than one client in the test grid... you can specify clients by number.
- """
- nodeargs = [
- "--node-directory", self.get_clientdir(i=client_num),
- ]
- argv = nodeargs + [verb] + list(args)
- stdin = kwargs.get("stdin", "")
- stdout, stderr = StringIO(), StringIO()
- d = threads.deferToThread(runner.runner, argv, run_by_human=False,
- stdin=StringIO(stdin),
- stdout=stdout, stderr=stderr)
- def _done(rc):
- return rc, stdout.getvalue(), stderr.getvalue()
- d.addCallback(_done)
- return d
-
def do_cli(self, verb, *args, **kwargs):
+ # client_num is used to execute client CLI commands on a specific client.
+ client_num = kwargs.get("client_num", 0)
+
nodeargs = [
- "--node-directory", self.get_clientdir(),
+ "--node-directory", self.get_clientdir(i=client_num),
]
argv = nodeargs + [verb] + list(args)
stdin = kwargs.get("stdin", "")
class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin):
def create_magic_folder(self, client_num):
- d = self.do_cli_n(client_num, "magic-folder", "create", "magic")
+ d = self.do_cli("magic-folder", "create", "magic", client_num=client_num)
def _done((rc,stdout,stderr)):
self.failUnless(rc == 0)
self.failUnless("Alias 'magic' created" in stdout)
return d
def invite(self, client_num, nickname):
- d = self.do_cli_n(client_num, "magic-folder", "invite", u"magic", nickname)
+ d = self.do_cli("magic-folder", "invite", u"magic", nickname, client_num=client_num)
def _done((rc,stdout,stderr)):
self.failUnless(rc == 0)
return (rc,stdout,stderr)
def join(self, client_num, local_dir, invite_code):
magic_readonly_cap, dmd_write_cap = invite_code.split(magic_folder_cli.INVITE_SEPERATOR)
- d = self.do_cli_n(client_num, "magic-folder", "join", invite_code, local_dir)
+ d = self.do_cli("magic-folder", "join", invite_code, local_dir, client_num=client_num)
def _done((rc,stdout,stderr)):
self.failUnless(rc == 0)
return (rc,stdout,stderr)
our upload directory.
"""
collective_readonly_cap = fileutil.read(os.path.join(self.get_clientdir(i=client_num), "private/collective_dircap"))
- d = self.do_cli_n(client_num, "ls", "--json", collective_readonly_cap)
+ d = self.do_cli("ls", "--json", collective_readonly_cap, client_num=client_num)
def _done((rc,stdout,stderr)):
self.failUnless(rc == 0)
return (rc,stdout,stderr)