def test_get_last_comment_containing_both_types_of_comments(self, mock_pr): github = GithubService() now = datetime.datetime.now() review_comment = test_mock.FakeGithubComment( author="user", body="a review comment", created_at=now - datetime.timedelta(minutes=1), ) issue_comment = test_mock.FakeGithubComment( author="user2", body="last issue comment", created_at=now ) mock_pr.get_comments.return_value = test_mock.FakeGithubPaginatedList( comments=[review_comment] ) mock_pr.get_issue_comments.return_value = test_mock.FakeGithubPaginatedList( comments=[issue_comment] ) last_comment = github.get_last_comment(mock_pr) self.assertEqual( last_comment, LastComment( author="user2", body="last issue comment", created_at=now ), )
def test_get_last_comment_containing_issue_comment(self, mock_pr): github = GithubService() now = datetime.datetime.now() issue_comment = test_mock.FakeGithubComment(author="user", body="a issue comment", created_at=now) mock_pr.get_comments.return_value = test_mock.FakeGithubPaginatedList( comments=[]) mock_pr.get_issue_comments.return_value = test_mock.FakeGithubPaginatedList( comments=[issue_comment]) last_comment = github.get_last_comment(mock_pr) self.assertEqual( last_comment, LastComment(author="user", body="a issue comment", created_at=now), )