Skip to content

Commit

Permalink
Merge branch 'master' into deepsource-transform-cd48f740
Browse files Browse the repository at this point in the history
  • Loading branch information
bartholomew-smith[bot] authored May 20, 2024
2 parents 95758c6 + b708528 commit 2710dc0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bartholomew.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pull_request_manager:
auto_approve: true
auto_approve_logins: ['deepsource-autofix[bot]']
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def default_configs() -> NoReturn:
merge_method="SQUASH",
auto_approve_logins=[],
auto_update=True,
auto_approve=False,
)
Config.create_config("release_manager", enabled=True)
Config.create_config(
Expand Down
2 changes: 1 addition & 1 deletion src/managers/pull_request_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def enable_auto_merge(pull_request: PullRequest, check_run: EventCheckRun) -> st
return ""


@Config.call_if("AUTO_APPROVE_PAT")
@Config.call_if("pull_request_manager.auto_approve")
def auto_approve(event: CheckSuiteRequestedEvent) -> NoReturn:
"""Approve the Pull Request if the branch creator is the same of the repository owner"""
repository = event.repository
Expand Down
25 changes: 25 additions & 0 deletions tests/managers/test_issue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
from github import Consts, UnknownObjectException
from githubapp import Config
from githubapp.events import IssueEditedEvent, IssueOpenedEvent
from githubapp.events.issues import IssueClosedEvent

Expand Down Expand Up @@ -422,6 +423,30 @@ def test_process_create_issue(issue_job):
assert job.job_status == JobStatus.UPDATE_ISSUE_BODY


def test_process_not_create_issue(issue_job):
JobService.insert_one(
Job(
original_issue_url=issue_job.issue_url,
task="task",
checked=False,
job_status=JobStatus.CREATE_ISSUE,
title="title",
)
)
repository = Mock()
with (
patch(
"src.managers.issue_manager._instantiate_github_class",
return_value=repository,
),
):
Config.issue_manager.create_issues_from_tasklist = False
process_create_issue(issue_job)
repository.create_issue.assert_not_called()
job = JobService.all()[0]
assert job.job_status == JobStatus.DONE


def test_process_update_issue_body(issue_job):
JobService.insert_many(
[
Expand Down
1 change: 1 addition & 0 deletions tests/managers/test_pull_request_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def test_auto_approve(event, repository, pull_request_helper):
pulls = [Mock() for _ in range(3)]
event.repository.get_pulls.return_value = pulls
Config.AUTO_APPROVE_PAT = "AUTO_APPROVE_PAT"
Config.pull_request_manager.auto_approve = True
auto_approve(event)
assert pull_request_helper.approve.call_count == len(pulls)
pull_request_helper.approve.assert_has_calls(
Expand Down

0 comments on commit 2710dc0

Please sign in to comment.