コード例 #1
0
 def parse_args(argument_string='', has_s3=False):
     with mock.patch(
         'detect_secrets_server.core.usage.s3.should_enable_s3_options',
         return_value=has_s3,
     ):
         return ServerParserBuilder().parse_args(
             argument_string.split()
         )
コード例 #2
0
 def parse_args(rootdir, argument_string=''):
     with mock.patch(
             'detect_secrets_server.core.usage.s3.should_enable_s3_options',
             return_value=False,
     ):
         return ServerParserBuilder().parse_args(
             'install cron --root-dir {} {}'.format(
                 rootdir,
                 argument_string,
             ).split())
コード例 #3
0
    def parse_args(argument_string=''):
        base_argument = ('scan will_be_mocked '
                         '--output-hook examples/standalone_hook.py ')

        with mock.patch(
                'detect_secrets_server.core.usage.s3.should_enable_s3_options',
                return_value=False,
        ):
            return ServerParserBuilder().parse_args(
                (base_argument + argument_string).split())
コード例 #4
0
    def parse_args(argument_string='', has_s3=False):
        base_argument = ('add will_be_mocked --config ')
        if has_s3:
            base_argument += '--s3-config examples/s3.yaml '

        with mock.patch(
                'detect_secrets_server.core.usage.s3.should_enable_s3_options',
                return_value=has_s3,
        ):
            return ServerParserBuilder().parse_args(
                (base_argument + argument_string).split())
コード例 #5
0
def test_version(capsys):
    with pytest.raises(SystemExit) as e:
        ServerParserBuilder().parse_args(['--version'])

    assert str(e.value) == '0'

    # Oh, the joys of writing compatible code
    if is_python_2():  # pragma: no cover
        assert capsys.readouterr().err.strip() == detect_secrets_server.__version__
    else:  # pragma: no cover
        assert capsys.readouterr().out.strip() == detect_secrets_server.__version__
コード例 #6
0
def parse_args(argv):
    return ServerParserBuilder().parse_args(argv)