Пример #1
0
def test_set_arg_parser():
    argument_parser = cli.get_argument_parser()

    def parse_args(arg_list):
        return argument_parser.parse_args(arg_list)

    parser = parse_args(['-v', '-p 12345'])
    assert parser.verbose is True
    assert parser.port == 12345
    parser = parse_args(['--web'])
    assert parser.action == 'web'
    parser = parse_args(['--genconf'])
    assert parser.action == 'genconf'
    parser = parse_args(['--hash-password', 'foo'])
    assert parser.password == 'foo'
    assert parser.action == 'hash-password'

    parser = parse_args(['--hash-password'])
    assert parser.password is None
    assert parser.action == 'hash-password'

    parser = parse_args(['--generate-node-upgrade-script', 'fake'])
    assert parser.installed_cluster_version == 'fake'
    assert parser.action == 'generate-node-upgrade-script'

    parser = parse_args(['--generate-node-upgrade-win-script', 'fake'])
    assert parser.installed_cluster_version == 'fake'
    assert parser.action == 'generate-node-upgrade-win-script'

    # Can't do two at once
    with pytest.raises(SystemExit):
        parse_args(['--validate', '--hash-password', 'foo'])
Пример #2
0
def test_set_arg_parser():
    argument_parser = cli.get_argument_parser()

    def parse_args(arg_list):
        return argument_parser.parse_args(arg_list)

    parser = parse_args(['-v', '-p 12345'])
    assert parser.verbose is True
    assert parser.port == 12345
    parser = parse_args(['--web'])
    assert parser.action == 'web'
    parser = parse_args(['--genconf'])
    assert parser.action == 'genconf'
    parser = parse_args(['--preflight'])
    assert parser.action == 'preflight'
    parser = parse_args(['--postflight'])
    assert parser.action == 'postflight'
    parser = parse_args(['--deploy'])
    assert parser.action == 'deploy'
    parser = parse_args(['--validate-config'])
    assert parser.action == 'validate-config'
    parser = parse_args(['--uninstall'])
    assert parser.action == 'uninstall'
    parser = parse_args(['--hash-password', 'foo'])
    assert parser.password == 'foo'
    assert parser.action == 'hash-password'

    parser = parse_args(['--hash-password'])
    assert parser.password is None
    assert parser.action == 'hash-password'

    parser = parse_args(['--set-superuser-password', 'foo'])
    assert parser.password == 'foo'
    assert parser.action == 'set-superuser-password'

    parser = parse_args(['--set-superuser-password'])
    assert parser.password is None
    assert parser.action == 'set-superuser-password'

    # Can't do two at once
    with pytest.raises(SystemExit):
        parse_args(['--validate', '--hash-password', 'foo'])
def test_default_arg_parser():
    parser = cli.get_argument_parser().parse_args([])
    assert parser.verbose is False
    assert parser.port == 9000
    assert parser.action == 'genconf'