mirror of
https://github.com/zulip/zulip.git
synced 2025-10-31 20:13:46 +00:00
integrations: Reformat Github issue assigned message body.
Instead of adding the assignee to the end of the message body, we update the message body where the verb is so that the link formatting at the end of the message is not broken, for example: "user_a assigned user_b to [issue #XXX title text is here](link)." Also updates the issue title in the test fixture so that it tests that only the first instance of "assigned" or "unassigned" in the issue title is updated for the assignee text. Also adds punctuation to the issue title in the test fixture to test the expected behavior for titles that end in a value from `string.punctuation`.
This commit is contained in:
committed by
Tim Abbott
parent
d82efbd503
commit
f6e17fa972
@@ -10,7 +10,7 @@
|
||||
"id": 1651035101,
|
||||
"node_id": "I_kwDOJRp_V85iaMvd",
|
||||
"number": 7,
|
||||
"title": "Sample Issue testing something",
|
||||
"title": "Testing when issue assigned!",
|
||||
"user": {
|
||||
"login": "sbansal1999",
|
||||
"id": 35286603,
|
||||
|
||||
@@ -160,14 +160,14 @@ class GitHubWebhookTest(WebhookTestCase):
|
||||
self.check_webhook("issues", expected_topic, expected_message)
|
||||
|
||||
def test_issue_assigned(self) -> None:
|
||||
expected_message = "sbansal1999 assigned [issue #7](https://github.com/sbansal1999/testing-gh/issues/7) to sbansal1999."
|
||||
expected_topic = "testing-gh / issue #7 Sample Issue testing something"
|
||||
expected_message = "sbansal1999 assigned sbansal1999 to [issue #7](https://github.com/sbansal1999/testing-gh/issues/7)."
|
||||
expected_topic = "testing-gh / issue #7 Testing when issue assigned!"
|
||||
self.check_webhook("issues__assigned", expected_topic, expected_message)
|
||||
|
||||
def test_issue_assigned_with_custom_topic_in_url(self) -> None:
|
||||
self.url = self.build_webhook_url(topic="notifications")
|
||||
expected_topic = "notifications"
|
||||
expected_message = "sbansal1999 assigned [issue #7 Sample Issue testing something](https://github.com/sbansal1999/testing-gh/issues/7) to sbansal1999."
|
||||
expected_message = "sbansal1999 assigned sbansal1999 to [issue #7 Testing when issue assigned!](https://github.com/sbansal1999/testing-gh/issues/7)"
|
||||
self.check_webhook("issues__assigned", expected_topic, expected_message)
|
||||
|
||||
def test_issue_unassigned(self) -> None:
|
||||
|
||||
@@ -170,9 +170,9 @@ def get_issue_body(helper: Helper) -> str:
|
||||
if has_assignee:
|
||||
stringified_assignee = payload["assignee"]["login"].tame(check_string)
|
||||
if action == "assigned":
|
||||
return f"{base_message[:-1]} to {stringified_assignee}."
|
||||
return base_message.replace("assigned", f"assigned {stringified_assignee} to", 1)
|
||||
elif action == "unassigned":
|
||||
return base_message.replace("unassigned", f"unassigned {stringified_assignee} from")
|
||||
return base_message.replace("unassigned", f"unassigned {stringified_assignee} from", 1)
|
||||
|
||||
return base_message
|
||||
|
||||
|
||||
Reference in New Issue
Block a user