Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
integrations: Add pull request comment fixture to GitHub Integration.
Satyam Bansal7ebf572b8e6f
diff --git a/zerver/webhooks/github/fixtures/issue_comment__pull_request_comment.json b/zerver/webhooks/github/fixtures/issue_comment__pull_request_comment.jsonnew file mode 100644index 00000000000..ca5708f457c--- /dev/null+++ b/zerver/webhooks/github/fixtures/issue_comment__pull_request_comment.json@@ -0,0 +1,235 @@+{+ "action": "created",+ "issue": {+ "url": "https://api.github.com/repos/sbansal1999/public-repo/issues/1",+ "repository_url": "https://api.github.com/repos/sbansal1999/public-repo",+ "labels_url": "https://api.github.com/repos/sbansal1999/public-repo/issues/1/labels{/name}",+ "comments_url": "https://api.github.com/repos/sbansal1999/public-repo/issues/1/comments",+ "events_url": "https://api.github.com/repos/sbansal1999/public-repo/issues/1/events",+ "html_url": "https://github.com/sbansal1999/public-repo/pull/1",+ "id": 1799681822,+ "node_id": "PR_kwDOJRp_V85VPfLc",+ "number": 1,+ "title": "Update the README with new information",+ "user": {+ "login": "sbansal1999",+ "id": 35286603,+ "node_id": "MDQ6VXNlcjM1Mjg2NjAz",+ "avatar_url": "https://avatars.githubusercontent.com/u/35286603?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/sbansal1999",+ "html_url": "https://github.com/sbansal1999",+ "followers_url": "https://api.github.com/users/sbansal1999/followers",+ "following_url": "https://api.github.com/users/sbansal1999/following{/other_user}",+ "gists_url": "https://api.github.com/users/sbansal1999/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/sbansal1999/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/sbansal1999/subscriptions",+ "organizations_url": "https://api.github.com/users/sbansal1999/orgs",+ "repos_url": "https://api.github.com/users/sbansal1999/repos",+ "events_url": "https://api.github.com/users/sbansal1999/events{/privacy}",+ "received_events_url": "https://api.github.com/users/sbansal1999/received_events",+ "type": "User",+ "site_admin": false+ },+ "labels": [],+ "state": "open",+ "locked": false,+ "assignee": null,+ "assignees": [],+ "milestone": null,+ "comments": 1,+ "created_at": "2023-07-11T20:10:07Z",+ "updated_at": "2023-07-11T20:10:13Z",+ "closed_at": null,+ "author_association": "OWNER",+ "active_lock_reason": null,+ "draft": false,+ "pull_request": {+ "url": "https://api.github.com/repos/sbansal1999/public-repo/pulls/1",+ "html_url": "https://github.com/sbansal1999/public-repo/pull/1",+ "diff_url": "https://github.com/sbansal1999/public-repo/pull/1.diff",+ "patch_url": "https://github.com/sbansal1999/public-repo/pull/1.patch",+ "merged_at": null+ },+ "body": null,+ "reactions": {+ "url": "https://api.github.com/repos/sbansal1999/public-repo/issues/1/reactions",+ "total_count": 0,+ "+1": 0,+ "-1": 0,+ "laugh": 0,+ "hooray": 0,+ "confused": 0,+ "heart": 0,+ "rocket": 0,+ "eyes": 0+ },+ "timeline_url": "https://api.github.com/repos/sbansal1999/public-repo/issues/1/timeline",+ "performed_via_github_app": null,+ "state_reason": null+ },+ "comment": {+ "url": "https://api.github.com/repos/sbansal1999/public-repo/issues/comments/1631445420",+ "html_url": "https://github.com/sbansal1999/public-repo/pull/1#issuecomment-1631445420",+ "issue_url": "https://api.github.com/repos/sbansal1999/public-repo/issues/1",+ "id": 1631445420,+ "node_id": "IC_kwDOJRp_V85hPeGs",+ "user": {+ "login": "sbansal1999",+ "id": 35286603,+ "node_id": "MDQ6VXNlcjM1Mjg2NjAz",+ "avatar_url": "https://avatars.githubusercontent.com/u/35286603?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/sbansal1999",+ "html_url": "https://github.com/sbansal1999",+ "followers_url": "https://api.github.com/users/sbansal1999/followers",+ "following_url": "https://api.github.com/users/sbansal1999/following{/other_user}",+ "gists_url": "https://api.github.com/users/sbansal1999/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/sbansal1999/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/sbansal1999/subscriptions",+ "organizations_url": "https://api.github.com/users/sbansal1999/orgs",+ "repos_url": "https://api.github.com/users/sbansal1999/repos",+ "events_url": "https://api.github.com/users/sbansal1999/events{/privacy}",+ "received_events_url": "https://api.github.com/users/sbansal1999/received_events",+ "type": "User",+ "site_admin": false+ },+ "created_at": "2023-07-11T20:10:12Z",+ "updated_at": "2023-07-11T20:10:12Z",+ "author_association": "OWNER",+ "body": "Some comment",+ "reactions": {+ "url": "https://api.github.com/repos/sbansal1999/public-repo/issues/comments/1631445420/reactions",+ "total_count": 0,+ "+1": 0,+ "-1": 0,+ "laugh": 0,+ "hooray": 0,+ "confused": 0,+ "heart": 0,+ "rocket": 0,+ "eyes": 0+ },+ "performed_via_github_app": null+ },+ "repository": {+ "id": 622493527,+ "node_id": "R_kgDOJRp_Vw",+ "name": "public-repo",+ "full_name": "sbansal1999/public-repo",+ "private": false,+ "owner": {+ "login": "sbansal1999",+ "id": 35286603,+ "node_id": "MDQ6VXNlcjM1Mjg2NjAz",+ "avatar_url": "https://avatars.githubusercontent.com/u/35286603?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/sbansal1999",+ "html_url": "https://github.com/sbansal1999",+ "followers_url": "https://api.github.com/users/sbansal1999/followers",+ "following_url": "https://api.github.com/users/sbansal1999/following{/other_user}",+ "gists_url": "https://api.github.com/users/sbansal1999/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/sbansal1999/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/sbansal1999/subscriptions",+ "organizations_url": "https://api.github.com/users/sbansal1999/orgs",+ "repos_url": "https://api.github.com/users/sbansal1999/repos",+ "events_url": "https://api.github.com/users/sbansal1999/events{/privacy}",+ "received_events_url": "https://api.github.com/users/sbansal1999/received_events",+ "type": "User",+ "site_admin": false+ },+ "html_url": "https://github.com/sbansal1999/public-repo",+ "description": null,+ "fork": false,+ "url": "https://api.github.com/repos/sbansal1999/public-repo",+ "forks_url": "https://api.github.com/repos/sbansal1999/public-repo/forks",+ "keys_url": "https://api.github.com/repos/sbansal1999/public-repo/keys{/key_id}",+ "collaborators_url": "https://api.github.com/repos/sbansal1999/public-repo/collaborators{/collaborator}",+ "teams_url": "https://api.github.com/repos/sbansal1999/public-repo/teams",+ "hooks_url": "https://api.github.com/repos/sbansal1999/public-repo/hooks",+ "issue_events_url": "https://api.github.com/repos/sbansal1999/public-repo/issues/events{/number}",+ "events_url": "https://api.github.com/repos/sbansal1999/public-repo/events",+ "assignees_url": "https://api.github.com/repos/sbansal1999/public-repo/assignees{/user}",+ "branches_url": "https://api.github.com/repos/sbansal1999/public-repo/branches{/branch}",+ "tags_url": "https://api.github.com/repos/sbansal1999/public-repo/tags",+ "blobs_url": "https://api.github.com/repos/sbansal1999/public-repo/git/blobs{/sha}",+ "git_tags_url": "https://api.github.com/repos/sbansal1999/public-repo/git/tags{/sha}",+ "git_refs_url": "https://api.github.com/repos/sbansal1999/public-repo/git/refs{/sha}",+ "trees_url": "https://api.github.com/repos/sbansal1999/public-repo/git/trees{/sha}",+ "statuses_url": "https://api.github.com/repos/sbansal1999/public-repo/statuses/{sha}",+ "languages_url": "https://api.github.com/repos/sbansal1999/public-repo/languages",+ "stargazers_url": "https://api.github.com/repos/sbansal1999/public-repo/stargazers",+ "contributors_url": "https://api.github.com/repos/sbansal1999/public-repo/contributors",+ "subscribers_url": "https://api.github.com/repos/sbansal1999/public-repo/subscribers",+ "subscription_url": "https://api.github.com/repos/sbansal1999/public-repo/subscription",+ "commits_url": "https://api.github.com/repos/sbansal1999/public-repo/commits{/sha}",+ "git_commits_url": "https://api.github.com/repos/sbansal1999/public-repo/git/commits{/sha}",+ "comments_url": "https://api.github.com/repos/sbansal1999/public-repo/comments{/number}",+ "issue_comment_url": "https://api.github.com/repos/sbansal1999/public-repo/issues/comments{/number}",+ "contents_url": "https://api.github.com/repos/sbansal1999/public-repo/contents/{+path}",+ "compare_url": "https://api.github.com/repos/sbansal1999/public-repo/compare/{base}...{head}",+ "merges_url": "https://api.github.com/repos/sbansal1999/public-repo/merges",+ "archive_url": "https://api.github.com/repos/sbansal1999/public-repo/{archive_format}{/ref}",+ "downloads_url": "https://api.github.com/repos/sbansal1999/public-repo/downloads",+ "issues_url": "https://api.github.com/repos/sbansal1999/public-repo/issues{/number}",+ "pulls_url": "https://api.github.com/repos/sbansal1999/public-repo/pulls{/number}",+ "milestones_url": "https://api.github.com/repos/sbansal1999/public-repo/milestones{/number}",+ "notifications_url": "https://api.github.com/repos/sbansal1999/public-repo/notifications{?since,all,participating}",+ "labels_url": "https://api.github.com/repos/sbansal1999/public-repo/labels{/name}",+ "releases_url": "https://api.github.com/repos/sbansal1999/public-repo/releases{/id}",+ "deployments_url": "https://api.github.com/repos/sbansal1999/public-repo/deployments",+ "created_at": "2023-04-02T09:31:40Z",+ "updated_at": "2023-07-09T17:15:18Z",+ "pushed_at": "2023-07-11T20:10:07Z",+ "git_url": "git://github.com/sbansal1999/public-repo.git",+ "ssh_url": "[email protected]:sbansal1999/public-repo.git",+ "clone_url": "https://github.com/sbansal1999/public-repo.git",+ "svn_url": "https://github.com/sbansal1999/public-repo",+ "homepage": null,+ "size": 3,+ "stargazers_count": 0,+ "watchers_count": 0,+ "language": null,+ "has_issues": true,+ "has_projects": true,+ "has_downloads": true,+ "has_wiki": true,+ "has_pages": false,+ "has_discussions": true,+ "forks_count": 0,+ "mirror_url": null,+ "archived": false,+ "disabled": false,+ "open_issues_count": 7,+ "license": null,+ "allow_forking": true,+ "is_template": false,+ "web_commit_signoff_required": false,+ "topics": [],+ "visibility": "public",+ "forks": 0,+ "open_issues": 7,+ "watchers": 0,+ "default_branch": "fixing-typo"+ },+ "sender": {+ "login": "sbansal1999",+ "id": 35286603,+ "node_id": "MDQ6VXNlcjM1Mjg2NjAz",+ "avatar_url": "https://avatars.githubusercontent.com/u/35286603?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/sbansal1999",+ "html_url": "https://github.com/sbansal1999",+ "followers_url": "https://api.github.com/users/sbansal1999/followers",+ "following_url": "https://api.github.com/users/sbansal1999/following{/other_user}",+ "gists_url": "https://api.github.com/users/sbansal1999/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/sbansal1999/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/sbansal1999/subscriptions",+ "organizations_url": "https://api.github.com/users/sbansal1999/orgs",+ "repos_url": "https://api.github.com/users/sbansal1999/repos",+ "events_url": "https://api.github.com/users/sbansal1999/events{/privacy}",+ "received_events_url": "https://api.github.com/users/sbansal1999/received_events",+ "type": "User",+ "site_admin": false+ }+}diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.pyindex 1bb3c564a51..62996566413 100644--- a/zerver/webhooks/github/tests.py+++ b/zerver/webhooks/github/tests.py@@ -145,6 +145,11 @@ class GitHubWebhookTest(WebhookTestCase):expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~"self.check_webhook("issue_comment", expected_topic, expected_message)+ def test_issue_comment_pull_request_comment_msg(self) -> None:+ expected_topic = "public-repo / issue #1 Update the README with new informa..."+ expected_message = "sbansal1999 [commented](https://github.com/sbansal1999/public-repo/pull/1#issuecomment-1631445420) on [issue #1](https://github.com/sbansal1999/public-repo/pull/1):\n\n~~~ quote\nSome comment\n~~~"+ self.check_webhook("issue_comment__pull_request_comment", expected_topic, expected_message)+def test_issue_msg(self) -> None:expected_message = "baxterthehacker opened [issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~"self.check_webhook("issues", TOPIC_ISSUE, expected_message)