def test_resolves_aliased_task(self): """Checks 'alias groups' feature about to resolve some group name to other group name Example: :bella-ciao:sh -> :sh """ context = ApplicationContext( tasks=[TaskDeclaration(ShellCommandTask())], aliases=[], directory='') context.compile() result_tasks = [] def assertion_callback(declaration: TaskDeclaration, task_num: int, parent: Union[GroupDeclaration, None] = None, args: list = []): result_tasks.append(declaration.to_full_name()) resolver = TaskResolver(context, parse_alias_groups_from_env(':bella-ciao->')) resolver.resolve([TaskArguments(':bella-ciao:sh', [])], assertion_callback) self.assertEqual([':sh'], result_tasks)
def test_parsed_count_matches(self): self.assertEqual( 2, len(parse_alias_groups_from_env(':harbor->:hb,:harbor->'))) self.assertEqual(0, len(parse_alias_groups_from_env('')))
def test_removes_previous_group_name(self): parsed = parse_alias_groups_from_env('->:harbor') self.assertEqual(':start', parsed[0].get_aliased_task_name(':harbor:start'))
def test_not_resolves_anything(self): parsed = parse_alias_groups_from_env( ':iwa->:international-workers-association') self.assertEqual(None, parsed[0].append_alias_to_task(':capitalism:sucks'))
def test_resolves_multiple_level_group(self): parsed = parse_alias_groups_from_env(':wl->:workers:liberation') self.assertEqual(':workers:liberation:strike', parsed[0].append_alias_to_task(':wl:strike'))
def test_resolves_single_level_group(self): parsed = parse_alias_groups_from_env( ':iwa->:international-workers-association') self.assertEqual(':international-workers-association:strike', parsed[0].append_alias_to_task(':iwa:strike'))
def test_resolves_from_empty_alias_destination_name(self): """Resolves :harbor:start into :harbor""" parsed = parse_alias_groups_from_env('->:harbor') self.assertEqual(':harbor:start', parsed[0].append_alias_to_task(':start'))