def can_grant_access_to_core_arg_parse_result(self): c = ParseResult([ParserContext(name="mytask")]) e = Executor(collection=Collection(), core=c) assert e.core is c # Sanity test of real-world access/usage assert len(e.core) == 1 assert e.core[0].name == "mytask" assert len(e.core[0].args) == 0
def hosts_flag_still_triggers_parameterization(self): body = Mock(pre=[], post=[]) coll = Collection(mytask=InvokeTask(body)) hosts = Argument(name="hosts") hosts.value = "host1,host2,host3" core_args = ParseResult([ParserContext(args=[hosts])]) Executor(coll, core=core_args).execute("mytask") assert body.call_count == 3
def execution_happens_normally_without_parameterization(self): body = Mock(pre=[], post=[]) coll = Collection(mytask=InvokeTask(body)) hosts = Argument(name="hosts") core_args = ParseResult([ParserContext(args=[hosts])]) # When #1824 present, this just blows up because no .hosts attr Executor(coll, core=core_args).execute("mytask") assert body.call_count == 1
def _get_executor(hosts_flag=None, hosts_kwarg=None, post=None, remainder=""): post_tasks = [] if post is not None: post_tasks.append(post) hosts = Argument(name="hosts") if hosts_flag is not None: hosts.value = hosts_flag core_args = ParseResult([ParserContext(args=[hosts])]) core_args.remainder = remainder task = Mock(pre=[], post=[]) coll = Collection(mytask=Task(task, post=post_tasks, hosts=hosts_kwarg)) return task, Executor(coll, core=core_args)
def can_grant_access_to_core_arg_parse_result(self): c = ParserContext() ok_(Executor(collection=Collection(), core=c).core is c)
def always_add_task_args_initial_context(self): from invoke.parser import ParserContext args = self.core_args() args += self.task_args() return ParserContext(args=args)