Exemple #1
0
 def status_reporter(self) -> StatusReporter:
     if not self._status_reporter:
         trigger = JobTriggerModel.get_or_create(
             type=self.db_trigger.job_trigger_model_type,
             trigger_id=self.db_trigger.id,
         )
         self._status_reporter = StatusReporter.get_instance(
             project=self.project,
             commit_sha=self.metadata.commit_sha,
             trigger_id=trigger.id if trigger else None,
             pr_id=self.metadata.pr_id,
         )
     return self._status_reporter
Exemple #2
0
def test_status_instead_check(
    project,
    commit_sha,
    pr_id,
    pr_object,
    state,
    title,
    summary,
    check_name,
    url,
    check_status,
    check_conclusion,
    commit_state_to_set,
    exception_mock,
    trigger_id,
):
    project = GithubProject(None, None, None)
    reporter = StatusReporter.get_instance(project=project,
                                           commit_sha=commit_sha,
                                           trigger_id=trigger_id,
                                           pr_id=pr_id)
    act_upon = flexmock(GithubProject)

    exception, exception_args, exception_kwargs = exception_mock
    act_upon.should_receive("create_check_run").with_args(
        name=check_name,
        commit_sha=commit_sha,
        url=url,
        external_id=str(trigger_id),
        status=check_status,
        conclusion=check_conclusion,
        output=create_github_check_run_output(title, summary),
    ).and_raise(exception, *exception_args, **exception_kwargs).once()

    act_upon.should_receive("set_commit_status").with_args(commit_sha,
                                                           commit_state_to_set,
                                                           url,
                                                           title,
                                                           check_name,
                                                           trim=True).once()

    reporter.set_status(state, title, check_name, url)
Exemple #3
0
def test_set_status_gitlab(commit_sha, pr_id, pr_object, state, description,
                           check_name, url, state_to_set):
    project = GitlabProject(None, None, None)
    reporter = StatusReporter.get_instance(project=project,
                                           commit_sha=commit_sha,
                                           pr_id=pr_id)
    act_upon = flexmock(
        pr_object.source_project) if pr_id else flexmock(GitlabProject)

    act_upon.should_receive("set_commit_status").with_args(commit_sha,
                                                           state_to_set,
                                                           url,
                                                           description,
                                                           check_name,
                                                           trim=True).once()

    if pr_id is not None:
        flexmock(GitlabProject).should_receive("get_pr").with_args(
            pr_id).and_return(pr_object)

    reporter.set_status(state, description, check_name, url)