Пример #1
0
def test_launch_only(capsys):
    del call_log[:]

    launch_jenkins.main()
    assert call_log[0] == ('parse_args', [])
    assert call_log[1] == ('launch_build', [build_url, params])
    assert call_log[2] == ('wait_queue', [queue_item])

    # even if it was launched with -q, it should output the build url to stdout
    captured = capsys.readouterr()
    assert not captured.err
    assert captured.out.strip() == build_url
Пример #2
0
def test_launch_jenkins_help(monkeypatch, capsys):
    new_argv = [__file__, '--help']
    monkeypatch.setattr(sys, 'argv', new_argv)
    with pytest.raises(SystemExit) as e:
        launch_jenkins.main()
        assert int(e.value) == 0

    captured = capsys.readouterr()
    out = captured.out.strip()

    assert 'Jenkins launcher' in out
    assert 'usage:' in out
    assert 'positional arguments:' in out
    assert 'optional arguments:' in out
Пример #3
0
def test_launch_jenkins_version(monkeypatch, capsys):
    new_argv = [__file__, '--version']
    monkeypatch.setattr(sys, 'argv', new_argv)
    with pytest.raises(SystemExit) as e:
        launch_jenkins.main()
        assert int(e.value) == 0

    captured = capsys.readouterr()
    expect = 'Jenkins launcher v{}'.format(__version__)
    if sys.version_info < (3, ):
        assert not captured.out
        assert captured.err.strip() == expect
    else:
        assert not captured.err
        assert captured.out.strip() == expect
Пример #4
0
def test_wait_main_invalid_url(monkeypatch):
    """
    Check that main() raises an error when specifying wait-only and passing a
    url without a build number at the end.
    """
    del call_log[:]

    basic_argv = [__file__, '-u', g_auth[0], '-t', g_auth[1], '-w']
    new_argv = list(basic_argv)  # not using list.copy because python2
    new_argv += ['-j', job_url]
    monkeypatch.setattr(sys, 'argv', new_argv)

    with pytest.raises(ValueError):
        launch_jenkins.main()
    assert not call_log
Пример #5
0
def test_launch_jenkins_main(monkeypatch):
    del call_log[:]

    monkeypatch.setitem(launch_jenkins.CONFIG, 'mode', 'full')
    assert launch_jenkins.main() == 0

    assert call_log[0] == ('parse_args', [])
    assert call_log[1] == ('launch_build', [build_url, params])
    assert call_log[2] == ('wait_queue', [queue_item])
    assert call_log[3] == ('wait_job', [build_url])
Пример #6
0
def test_launch_jenkins_main_fail(monkeypatch):
    assert launch_jenkins.main() == 1
Пример #7
0
def test_wait_main_fail():
    assert launch_jenkins.main() == 1
Пример #8
0
def test_wait_only():
    del call_log[:]

    assert launch_jenkins.main() == 0
    assert call_log[0] == ('parse_args', [])
    assert call_log[1] == ('wait_job', [build_url])