def test_comment_match_decodes_comment_for_pr(): id = "<comment_id>" plan = "<plan>" comment_for_pr = comment_util.comment_for_pr(id, plan) match = comment_util.re_comment_match(id, comment_for_pr) assert match.group(1).strip() == plan assert match.group(2).strip() == ""
def __init__(self, pr_url: str): self._plan = None self._status = None response = github.get(pr_url) response.raise_for_status() self._issue_url = response.json( )['_links']['issue']['href'] + '/comments' response = github.get(self._issue_url) response.raise_for_status() self._comment_url = None for comment in response.json(): if comment['user']['login'] == github_username: match = comment_util.re_comment_match(self._comment_identifier, comment['body']) if match: self._comment_url = comment['url'] self._plan = match.group(1).strip() self._status = match.group(2).strip() return
def test_regex_comment_match(comment_id, comment_body, match_group_one, match_group_two): match = comment_util.re_comment_match(comment_id, comment_body) assert match.group(1).strip() == match_group_one assert match.group(2).strip() == match_group_two