Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pending label #38

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions reusable_workflows/check_cla/check_cla_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ def create_cla_issue(self, user: str) -> GHIssue:
user, self.cla_link, user_agreement_message
),
)
# replace with PENDING, once new bot has been released
issue.add_labels(GH_WORKFLOW_LABEL)
issue.add_labels(PENDING_LABEL)
return issue

def handle_cla_signed(self, issue: GHIssue, user: str) -> None:
for label in issue.original_labels:
if label.name == APPROVED_LABEL:
return
elif label.name == GH_WORKFLOW_LABEL:
agreement_message = messages.AGREED_MESSAGE.format(user)
issue.create_comment(agreement_message)
issue.remove_label(GH_WORKFLOW_LABEL)
issue.add_labels(APPROVED_LABEL)
return
for pending_label in [GH_WORKFLOW_LABEL, PENDING_LABEL]:
if label.name == pending_label:
agreement_message = messages.AGREED_MESSAGE.format(user)
issue.create_comment(agreement_message)
issue.remove_label(pending_label)
issue.add_labels(APPROVED_LABEL)
return
print(
"No cla labels found - manually check the cla issue to see what state it is in. Exiting program." # noqa
)
Expand Down
14 changes: 14 additions & 0 deletions reusable_workflows/tests/test_cla_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def test_create_cla_issue():
"cla: @username",
body=cla_agreement_message,
)
issue.add_labels.assert_called_with("cla:pending")


def test_handle_cla_signed_with_agreed_label():
Expand Down Expand Up @@ -171,6 +172,19 @@ def test_handle_cla_signed_with_pending_label():
issue.remove_label.assert_called_once()
issue.add_labels.assert_called_once()

def test_handle_cla_signed_with_new_pending_label():
issue = mock.Mock()
label = mock.Mock()
label.name = "cla:pending"
issue.original_labels = [label]
agreement_message = AGREED_MESSAGE.format("username")

cla = CLAHandler(mock.Mock())
cla.handle_cla_signed(issue, "username")

issue.create_comment.assert_called_with(agreement_message)
issue.remove_label.assert_called_once()
issue.add_labels.assert_called_once()

def test_handle_cla_signed_with_no_label(capfd):
issue = mock.Mock()
Expand Down