Пример #1
0
def test_main_some_pipelines_csv_export(set_argv, set_pipelines,
                                        set_git_remote_url, capsys, tmp_path):
    jobs_csv = tmp_path / "jobs.csv"
    set_argv(['gitlab-jobs', '--csv', str(jobs_csv)])
    set_git_remote_url('https://gitlab.com/mgedmin/example-project')
    set_pipelines([
        Pipeline(id=1, jobs=[
            Job(id=1001),
        ]),
    ])
    glj.main()
    stdout = capsys.readouterr().out.replace(str(jobs_csv), '/tmp/jobs.csv')
    assert stdout == textwrap.dedent('''\
        Determined the GitLab project to be mgedmin/example-project
        Last 20 successful pipelines of example-project master:
          1 (2020-04-29, commit 356a192b, duration 0.6m)

        Summary:
          tests    min  0.3m, max  0.3m, avg  0.3m, median  0.3m, stdev  0.0m
          overall  min  0.6m, max  0.6m, avg  0.6m, median  0.6m, stdev  0.0m

        Writing /tmp/jobs.csv...
    ''')
    assert jobs_csv.read_text() == textwrap.dedent('''\
      tests,16.589658
      overall,38
    ''')
Пример #2
0
def test_main_no_pipelines(set_git_remote_url, capsys):
    set_git_remote_url('https://gitlab.com/mgedmin/example-project')
    glj.main()
    assert capsys.readouterr().out == textwrap.dedent('''\
        Determined the GitLab project to be mgedmin/example-project
        Last 20 successful pipelines of example-project master:

        No finished pipelines found.
    ''')
Пример #3
0
def test_main_some_pipelines_debug(
    set_argv,
    set_pipelines,
    set_git_remote_url,
):
    set_argv(['gitlab-jobs', '--verbose', '--debug'])
    set_git_remote_url('https://gitlab.com/mgedmin/example-project')
    set_pipelines([
        Pipeline(id=1, duration=None, jobs=[
            Job(id=1001, status='failed'),
        ]),
    ])
    glj.main()
Пример #4
0
def test_main_some_pipelines_all_statuses(set_argv, set_pipelines,
                                          set_git_remote_url, capsys):
    set_argv(['gitlab-jobs', '--all-pipelines'])
    set_git_remote_url('https://gitlab.com/mgedmin/example-project')
    set_pipelines([
        Pipeline(id=1, duration=None, status='failed'),
    ])
    glj.main()
    assert capsys.readouterr().out == textwrap.dedent('''\
        Determined the GitLab project to be mgedmin/example-project
        Last 20 pipelines of example-project master:
          1 (2020-04-29, commit 356a192b) - failed

        No finished pipelines found.
    ''')
Пример #5
0
def test_main_some_pipelines(set_pipelines, set_git_remote_url, capsys):
    set_git_remote_url('https://gitlab.com/mgedmin/example-project')
    set_pipelines([
        Pipeline(id=2, duration=None),
        Pipeline(id=1),
    ])
    glj.main()
    assert capsys.readouterr().out == textwrap.dedent('''\
        Determined the GitLab project to be mgedmin/example-project
        Last 20 successful pipelines of example-project master:
          2 (2020-04-29, commit da4b9237)
          1 (2020-04-29, commit 356a192b, duration 0.6m)

        Summary:
          overall  min  0.6m, max  0.6m, avg  0.6m, median  0.6m, stdev  0.0m
    ''')
Пример #6
0
def test_main_some_pipelines_verbose(set_argv, set_pipelines,
                                     set_git_remote_url, capsys):
    set_argv(['gitlab-jobs', '-v'])
    set_git_remote_url('https://gitlab.com/mgedmin/example-project')
    set_pipelines([
        Pipeline(id=1, duration=None, jobs=[
            Job(id=1001),
        ]),
    ])
    glj.main()
    assert capsys.readouterr().out == textwrap.dedent('''\
        Determined the GitLab project to be mgedmin/example-project
        Last 20 successful pipelines of example-project master:
          1 (2020-04-29, commit 356a192b by Marius)
            tests                            0.3m

        No finished pipelines found.
    ''')
Пример #7
0
def test_main_no_project():
    with pytest.raises(SystemExit):
        glj.main()
Пример #8
0
def test_main__help(set_argv):
    set_argv(['gitlab-jobs', '--help'])
    with pytest.raises(SystemExit):
        glj.main()