Server IP : 85.214.239.14 / Your IP : 3.149.24.70 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/ansible_test/_internal/cli/commands/integration/ |
Upload File : |
"""Command line parsing for the `network-integration` command.""" from __future__ import annotations import argparse import collections.abc as c import os import typing as t from ....commands.integration.network import ( command_network_integration, ) from ....config import ( NetworkIntegrationConfig, ) from ....target import ( walk_network_integration_targets, ) from ....data import ( data_context, ) from ...environments import ( CompositeActionCompletionFinder, ControllerMode, TargetMode, add_environments, ) from ...completers import ( register_completer, ) def do_network_integration( subparsers, parent: argparse.ArgumentParser, add_integration_common: c.Callable[[argparse.ArgumentParser], None], completer: CompositeActionCompletionFinder, ): """Command line parsing for the `network-integration` command.""" parser: argparse.ArgumentParser = subparsers.add_parser( 'network-integration', parents=[parent], help='network integration tests', ) parser.set_defaults( func=command_network_integration, targets_func=walk_network_integration_targets, config=NetworkIntegrationConfig, ) network_integration = t.cast(argparse.ArgumentParser, parser.add_argument_group(title='network integration test arguments')) add_integration_common(network_integration) register_completer(network_integration.add_argument( '--testcase', metavar='TESTCASE', help='limit a test to a specified testcase', ), complete_network_testcase) add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.NETWORK_INTEGRATION) # network-integration def complete_network_testcase(prefix: str, parsed_args: argparse.Namespace, **_) -> list[str]: """Return a list of test cases matching the given prefix if only one target was parsed from the command line, otherwise return an empty list.""" testcases = [] # since testcases are module specific, don't autocomplete if more than one # module is specified if len(parsed_args.include) != 1: return [] target = parsed_args.include[0] test_dir = os.path.join(data_context().content.integration_targets_path, target, 'tests') connection_dirs = data_context().content.get_dirs(test_dir) for connection_dir in connection_dirs: for testcase in [os.path.basename(path) for path in data_context().content.get_files(connection_dir)]: if testcase.startswith(prefix): testcases.append(testcase.split('.', 1)[0]) return testcases