Пример #1
0
def test_launch_wait_only(arg, url, mode, monkeypatch, config):
    new_argv = ['python', '-j', url, '-u', g_auth[0], '-t', g_auth[1]]
    if arg:
        new_argv += [arg]
    monkeypatch.setattr(sys, 'argv', new_argv)
    parse_args()
    assert launch_jenkins.CONFIG['mode'] == mode
Пример #2
0
def test_dump_flag(monkeypatch, config):
    """
    Test that --dump sets `sys.stdout` as the job output file.
    """
    params = ['--dump']
    new_argv = ['python'] + g_params + params
    monkeypatch.setattr(sys, 'argv', new_argv)
    parse_args()
    assert launch_jenkins.CONFIG['output'] is sys.stdout
Пример #3
0
def test_optional_flags(monkeypatch, config):
    """
    Check that the known optional flags are accepted.
    """
    params = ['-q', '--dump', '--progress']
    new_argv = ['python'] + g_params + params
    monkeypatch.setattr(sys, 'argv', new_argv)
    parse_args()
    assert launch_jenkins.CONFIG['output']
    assert launch_jenkins.CONFIG['quiet']
    assert launch_jenkins.CONFIG['progress']
Пример #4
0
def test_argv_params(monkeypatch):
    params = [
        'key=value',
        'keyt=other value',
        'empty=',
        'truth=1 == 0',
        's p a c e s = are cool',
    ]
    build_params = {
        'key': 'value',
        'keyt': 'other value',
        'empty': '',
        'truth': '1 == 0',
        's p a c e s': 'are cool',
    }
    new_argv = ['python'] + g_params + params
    monkeypatch.setattr(sys, 'argv', new_argv)
    launch_params = parse_args()
    assert launch_params == (g_url, g_auth, build_params)
Пример #5
0
def test_output_flag(monkeypatch, config):
    """
    Test that --output can take an argument and set it as the job output file.
    """
    params = ['--output', '/tmp/output']
    new_argv = ['python'] + g_params + params
    monkeypatch.setattr(sys, 'argv', new_argv)
    parse_args()
    assert launch_jenkins.CONFIG['output'] == '/tmp/output'

    new_argv[-1] = '-'
    monkeypatch.setattr(sys, 'argv', new_argv)
    parse_args()
    assert launch_jenkins.CONFIG['output'] is sys.stdout

    del new_argv[-1]
    monkeypatch.setattr(sys, 'argv', new_argv)
    parse_args()
    assert launch_jenkins.CONFIG['output'] is True
Пример #6
0
def test_argv_params_wrong_format(monkeypatch, params):
    new_argv = ['python'] + g_params + params
    monkeypatch.setattr(sys, 'argv', new_argv)
    with pytest.raises(ValueError) as error:
        parse_args()
        assert 'use key=value format' in error.value
Пример #7
0
def test_basic_argv(monkeypatch):
    new_argv = ['python'] + g_params
    monkeypatch.setattr(sys, 'argv', new_argv)
    launch_params = parse_args()
    assert launch_params == (g_url, g_auth, {})
Пример #8
0
def test_parse_incompatible_args(monkeypatch, args):
    new_argv = ['python'] + g_params + args
    monkeypatch.setattr(sys, 'argv', new_argv)
    with pytest.raises(SystemExit) as error:
        parse_args()
        assert 'not allowed with argument' in str(error.value)
Пример #9
0
def test_parse_incomplete_args(monkeypatch, args):
    new_argv = ['python'] + args
    monkeypatch.setattr(sys, 'argv', new_argv)
    with pytest.raises(SystemExit):
        parse_args()