def when_check_ci_is_called_but_finds_no_job_raises_exeption(self, mocker, capsys ):
        # Given
        commit_sha1 = 'commit_sha_12345'
        mocker.patch('scripts.check_ci_status.get_project_jobs_infos', return_value = False)

        # When
        with pytest.raises(SystemExit) as pytest_wrapped_e:
            sys.argv = ["scripts/check_ci_status.py", commit_sha1]
            main()

        # Then
        assert pytest_wrapped_e.value.code == 1
Пример #2
0
    def when_check_ci_is_called_without_an_argument_exits_system(self, capsys):
        # Given
        sys.argv = ["scripts/check_ci_status.py"]

        # When
        with pytest.raises(SystemExit) as pytest_wrapped_e:
            sys.argv = ["scripts/check_ci_status.py"]
            main()
        out, err = capsys.readouterr()

        # Then
        assert pytest_wrapped_e.type == SystemExit
        assert pytest_wrapped_e.value.code == 1
    def when_check_ci_is_called_and_commit_is_successful(self, mocker, capsys ):
        # Given
        commit_sha1 = 'commit_sha_12345'
        tag_name = '1.2.3'
        mocker.patch('scripts.check_ci_status.get_project_jobs_infos', return_value = project_jobs_infos_mock)
        mocker.patch('scripts.check_ci_status.extract_commit_status', return_value = "success")

        # When
        with pytest.raises(SystemExit) as pytest_wrapped_e:
            sys.argv = ["scripts/check_ci_status.py", commit_sha1, tag_name]
            main()

        # Then
        assert pytest_wrapped_e.value.code == 0