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
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
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']
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)
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
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
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, {})
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)
def test_parse_incomplete_args(monkeypatch, args): new_argv = ['python'] + args monkeypatch.setattr(sys, 'argv', new_argv) with pytest.raises(SystemExit): parse_args()