Exemplo n.º 1
0
def comments():
    return [
        PRComment(
            body="Abc def ghi.",
            author="Mr. Smith",
            created=datetime.datetime(2019, 1, 18, 10, 14, 5),
            edited=datetime.datetime(2019, 1, 18, 10, 18, 5),
        ),
        PRComment(
            body="something 12345 different",
            author="Mr. Bean",
            created=datetime.datetime(2019, 1, 18, 10, 14, 5),
            edited=datetime.datetime(2019, 1, 18, 10, 18, 5),
        ),
        PRComment(
            body="Just a comment.",
            author="Mr. Doe",
            created=datetime.datetime(2019, 1, 18, 10, 14, 5),
            edited=datetime.datetime(2019, 1, 18, 10, 18, 5),
        ),
        PRComment(
            body="Just some notes.",
            author="Mr. Brown",
            created=datetime.datetime(2019, 1, 18, 10, 14, 5),
            edited=datetime.datetime(2019, 1, 18, 10, 18, 5),
        ),
    ]
Exemplo n.º 2
0
 def _prcomment_from_github_object(raw_comment: GithubIssueComment) -> PRComment:
     return PRComment(
         comment=raw_comment.body,
         author=raw_comment.user.login,
         created=raw_comment.created_at,
         edited=raw_comment.updated_at,
     )
Exemplo n.º 3
0
 def _prcomment_from_gitlab_object(raw_comment) -> PRComment:
     return PRComment(
         comment=raw_comment.body,
         author=raw_comment.author["username"],
         created=raw_comment.created_at,
         edited=raw_comment.updated_at,
     )
Exemplo n.º 4
0
 def test_run_once(self):
     """Test that the bot runs only once and exits."""
     flexmock(self.release_bot.conf, refresh_interval=None)
     flexmock(self.release_bot.github, comment=["foo", "bar"])
     (flexmock(
         self.release_bot.project)  # make sure it walks through the loop
      .should_receive("pr_comment").once().and_return(
          PRComment(body="Fake comment", author="FakeAuthor")))
     self.release_bot.run()
Exemplo n.º 5
0
 def _prcomment_from_pagure_dict(comment_dict: dict) -> PRComment:
     return PRComment(
         comment=comment_dict["comment"],
         author=comment_dict["user"]["name"],
         created=datetime.datetime.fromtimestamp(int(comment_dict["date_created"])),
         edited=datetime.datetime.fromtimestamp(int(comment_dict["edited_on"]))
         if comment_dict["edited_on"]
         else None,
     )
Exemplo n.º 6
0
 def pr_comment(
     cls,
     original_object: Any,
     pr_id: int,
     body: str,
     commit: str = None,
     filename: str = None,
     row: int = None,
 ) -> "PRComment":
     pull_request = original_object.get_pr(pr_id)
     log_output(pull_request)
     return PRComment(
         parent=pull_request,
         body=body,
         author=cls.author,
         created=datetime.datetime.now(),
         edited=datetime.datetime.now(),
     )
Exemplo n.º 7
0
    def pr_comment(
        self,
        pr_id: int,
        body: str,
        commit: str = None,
        filename: str = None,
        row: int = None,
    ) -> PRComment:
        payload: Dict[str, Any] = {"comment": body}
        if commit is not None:
            payload["commit"] = commit
        if filename is not None:
            payload["filename"] = filename
        if row is not None:
            payload["row"] = row

        self._call_project_api(
            "pull-request", str(pr_id), "comment", method="POST", data=payload
        )

        return PRComment(comment=body, author=self.service.user.get_username())