diff --git a/bot/github/github_parsers.py b/bot/github/github_parsers.py index 84e2c58..55c5692 100644 --- a/bot/github/github_parsers.py +++ b/bot/github/github_parsers.py @@ -488,7 +488,7 @@ def cast_payload_to_event(event_type: str, json: JSON) -> GitHubEvent: link=json["pull_request"]["html_url"], ), comments=[json["comment"]["body"]], - links=[Link(url=json["comment"]["url"])], + links=[Link(url=json["comment"]["html_url"])], ) diff --git a/bot/models/github/event.py b/bot/models/github/event.py index 832ed8e..9b62670 100644 --- a/bot/models/github/event.py +++ b/bot/models/github/event.py @@ -59,7 +59,7 @@ def __init__(self, event_type: EventType, repo: Repository, **kwargs): if "links" in kwargs: self.links = kwargs["links"] if "reviewers" in kwargs: - self.comments = kwargs["reviewers"] + self.reviewers = kwargs["reviewers"] def __str__(self): string = "" diff --git a/tests/github/data.json b/tests/github/data.json index 3d47229..6614955 100644 --- a/tests/github/data.json +++ b/tests/github/data.json @@ -21,5 +21,496 @@ "type": "EventType.BRANCH_CREATED", "user": "" } + ], + "branch_delete": [ + { + "event_type": "delete", + "raw_json": { + "ref": "branch-name", + "ref_type": "branch", + "pusher_type": "user", + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "example-user" + } + } + }, + { + "ref": "branch-name", + "repo": "", + "type": "EventType.BRANCH_DELETED", + "user": "" + } + ], + "commit_comment": [ + { + "event_type": "commit_comment", + "raw_json": { + "action": "created", + "comment": { + "html_url": "https://github.com/example-org/example-repo/commit/4d93b5294b201237#commitcomment-12345678", + "user": { + "login": "example-user" + }, + "commit_id": "4d93b5294b201237", + "body": "comment content" + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "example-user" + } + } + }, + { + "comments": ["comment content"], + "commits": ["<|https://github.com/example-org/example-repo/commit/4d93b529>"], + "links": [""], + "repo": "", + "type": "EventType.COMMIT_COMMENT", + "user": "" + } + ], + "fork": [ + { + "event_type": "fork", + "raw_json": { + "forkee": { + "owner": { + "login": "user-who-forked" + }, + "html_url": "https://github.com/user-who-forked/example-repo" + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + } + } + }, + { + "links": [""], + "repo": "", + "type": "EventType.FORK", + "user": "" + } + ], + "push": [ + { + "event_type": "push", + "raw_json": { + "ref": "refs/heads/branch-name", + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "pusher": { + "name": "user-who-pushed" + }, + "sender": { + "login": "user-who-pushed" + }, + "commits": [ + { + "id": "f30421319e41a3a", + "message": "commit-message1" + }, + { + "id": "5g0521417e40i37d9", + "message": "commit-message2" + } + + ] + } + }, + { + "commits": ["", ""], + "ref": "branch-name", + "repo": "", + "type": "EventType.PUSH", + "user": "" + } + ], + "star_add": [ + { + "event_type": "star", + "raw_json": { + "action": "created", + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-starred" + } + } + }, + { + "repo": "", + "type": "EventType.STAR_ADDED", + "user": "" + } + ], + "star_remove": [ + { + "event_type": "star", + "raw_json": { + "action": "deleted", + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-unstarred" + } + } + }, + { + "repo": "", + "type": "EventType.STAR_REMOVED", + "user": "" + } + ], + "issue_open": [ + { + "event_type": "issues", + "raw_json": { + "action": "opened", + "issue": { + "html_url": "https://github.com/example-org/example-repo/issues/3", + "number": 3, + "title": "ExampleIssue", + "user": { + "login": "user-who-opened-issue" + } + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-opened-issue" + } + } + }, + { + "repo": "", + "type": "EventType.ISSUE_OPENED", + "user": "", + "issue": "" + } + ], + "issue_close": [ + { + "event_type": "issues", + "raw_json": { + "action": "closed", + "issue": { + "html_url": "https://github.com/example-org/example-repo/issues/3", + "number": 3, + "title": "ExampleIssue", + "user": { + "login": "user-who-closed-issue" + } + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-closed-issue" + } + } + }, + { + "repo": "", + "type": "EventType.ISSUE_CLOSED", + "user": "", + "issue": "" + } + ], + "issue_comment": [ + { + "event_type": "issue_comment", + "raw_json": { + "action": "created", + "issue": { + "html_url": "https://github.com/example-org/example-repo/issues/3", + "number": 3, + "title": "ExampleIssue" + }, + "comment": { + "html_url": "https://github.com/example-org/example-repo/issues/3#issuecomment-1234567890", + "body": "comment content" + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-commented" + } + } + }, + { + "repo": "", + "type": "EventType.ISSUE_COMMENT", + "user": "", + "issue": "", + "comments": ["comment content"], + "links": [""] + } + ], + "pull_close": [ + { + "event_type": "pull_request", + "raw_json": { + "action": "closed", + "number": 3, + "pull_request": { + "html_url": "https://github.com/example-org/example-repo/pull/3", + "number": 3, + "title": "ExamplePR", + "user": { + "login": "user-who-closed-PR" + }, + "merged": false + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + } + } + }, + { + "repo": "", + "type": "EventType.PULL_CLOSED", + "user": "", + "pull_request": "" + } + ], + "pull_merge": [ + { + "event_type": "pull_request", + "raw_json": { + "action": "closed", + "number": 3, + "pull_request": { + "html_url": "https://github.com/example-org/example-repo/pull/3", + "number": 3, + "title": "ExamplePR", + "user": { + "login": "user-who-merged-PR" + }, + "merged": true + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + } + } + }, + { + "repo": "", + "type": "EventType.PULL_MERGED", + "user": "", + "pull_request": "" + } + ], + "pull_open": [ + { + "event_type": "pull_request", + "raw_json": { + "action": "opened", + "number": 3, + "pull_request": { + "html_url": "https://github.com/example-org/example-repo/pull/3", + "number": 3, + "title": "ExamplePR", + "user": { + "login": "user-who-opened-PR" + } + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + } + } + }, + { + "repo": "", + "type": "EventType.PULL_OPENED", + "user": "", + "pull_request": "" + } + ], + "pull_ready": [ + { + "event_type": "pull_request", + "raw_json": { + "action": "review_requested", + "pull_request": { + "html_url": "https://github.com/example-org/example-repo/pull/3", + "number": 3, + "title": "ExamplePR", + "requested_reviewers": [ + { + "login": "reviewer1" + }, + { + "login": "reviewer2" + } + ] + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + } + } + }, + { + "repo": "", + "type": "EventType.PULL_READY", + "reviewers": ["",""], + "pull_request": "" + } + ], + "release": [ + { + "event_type": "release", + "raw_json": { + "action": "released", + "release": { + "tag_name": "example-tag" + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "example-user" + } + } + }, + { + "ref": "example-tag", + "repo": "", + "type": "EventType.RELEASE", + "status": "created", + "user": "" + } + ], + "review": [ + { + "event_type": "pull_request_review", + "raw_json": { + "action": "submitted", + "review": { + "state": "changes_requested" + }, + "pull_request": { + "html_url": "https://github.com/example-org/example-repo/pull/3", + "number": 3, + "title": "ExamplePR" + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "reviewer" + } + } + }, + { + "repo": "", + "type": "EventType.REVIEW", + "pull_request": "", + "status": "changes_requested", + "reviewers": [""] + } + ], + "review_comment": [ + { + "event_type": "pull_request_review_comment", + "raw_json": { + "action": "created", + "comment": { + "url": "https://api.github.com/repos/example-org/example-repo/pulls/comments/123456789", + "html_url": "https://github.com/example-org/example-repo/pull/3#discussion_r123456789", + "body": "comment content" + }, + "pull_request": { + "html_url": "https://github.com/example-org/example-repo/pull/3", + "number": 3, + "title": "ExamplePR" + }, + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-commented" + } + } + }, + { + "repo": "", + "type": "EventType.REVIEW_COMMENT", + "user": "", + "pull_request": "", + "comments": ["comment content"], + "links": [""] + } + ], + "tag_create": [ + { + "event_type": "create", + "raw_json": { + "ref": "example-tag", + "ref_type": "tag", + "pusher_type": "user", + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-created-tag" + } + } + }, + { + "ref": "example-tag", + "repo": "", + "type": "EventType.TAG_CREATED", + "user": "" + } + ], + "tag_delete": [ + { + "event_type": "delete", + "raw_json": { + "ref": "example-tag", + "ref_type": "tag", + "pusher_type": "user", + "repository": { + "full_name": "example-org/example-repo", + "html_url": "https://github.com/example-org/example-repo" + }, + "sender": { + "login": "user-who-deleted-tag" + } + } + }, + { + "ref": "example-tag", + "repo": "", + "type": "EventType.TAG_DELETED", + "user": "" + } ] }