def test_render_issue_without_prod_comment(self): issue_number = self.issue_number_without_prod_comment tag = self.tag_prod # Mock the issue api_url = "{}/issues/{}".format(self.repo_api_url, issue_number) expected_issue = self._get_expected_issue(issue_number) responses.add(method=responses.GET, url=api_url, json=expected_issue) # Mock the comments list api_url = "{}/issues/{}/comments".format(self.repo_api_url, issue_number) expected_comment_1 = self._get_expected_issue_comment("Some other comment") expected_comments = [expected_comment_1] responses.add(method=responses.GET, url=api_url, body=[], content_type="application/json") # Mock the comment post response api_url = "{}/issues/{}/comments".format(self.repo_api_url, issue_number) expected_comment_1 = self._get_expected_issue_comment( "{} {}".format(CommentingGithubIssuesParser.message_prod, self.version_number_prod) ) responses.add(method=responses.POST, url=api_url, json=expected_comment_1) generator = self._create_generator(tag) parser = CommentingGithubIssuesParser(generator, self.title) parser.content = [issue_number] expected_render = "# {}\r\n\r\n#{}: {}".format(self.title, issue_number, expected_issue["title"]) self.assertEqual(parser.render(), expected_render) # 3 api calls were made, ensuring comment creation # was attempted self.assertEqual(len(responses.calls._calls), 3)
def test_render_issue_with_prod_comment(self): issue_number = self.issue_number_with_prod_comment tag = self.tag_prod # Mock the issue api_url = '{}/issues/{}'.format( self.repo_api_url, issue_number, ) expected_issue = self._get_expected_issue(issue_number) responses.add( method=responses.GET, url=api_url, json=expected_issue, ) # Mock the comments list api_url = '{}/issues/{}/comments'.format( self.repo_api_url, issue_number, ) expected_comment_1 = self._get_expected_issue_comment( CommentingGithubIssuesParser.message_prod, ) expected_comments = [ expected_comment_1, ] responses.add( method=responses.GET, url=api_url, json=expected_comments, ) generator = self._create_generator(tag) parser = CommentingGithubIssuesParser(generator, self.title) parser.content = [{ 'issue_number': issue_number, 'pr_number': self.pr_number, 'pr_url': self.pr_url, }] expected_render = self._create_expected_render( issue_number, expected_issue['title'], False, ) self.assertEqual(parser.render(), expected_render) # Only 2 api calls were made, ensuring comment creation # was not attempted self.assertEqual(len(responses.calls._calls), 2)
def test_render_issue_without_comments(self): issue_number = self.issue_number_without_comments tag = self.tag_not_prod_or_beta # Mock the issue api_url = '{}/issues/{}'.format( self.repo_api_url, issue_number, ) expected_issue = self._get_expected_issue(issue_number) responses.add( method=responses.GET, url=api_url, json=expected_issue, ) # Mock the comments list api_url = '{}/issues/{}/comments'.format( self.repo_api_url, issue_number, ) responses.add( method=responses.GET, url=api_url, body=[], content_type='application/json', ) generator = self._create_generator(tag) parser = CommentingGithubIssuesParser(generator, self.title) parser.content = [issue_number] expected_render = '# {}\r\n\r\n#{}: {}'.format( self.title, issue_number, expected_issue['title'], ) self.assertEqual(parser.render(), expected_render) # Only 2 api calls were made, ensuring comment creation # was not attempted self.assertEqual(len(responses.calls._calls), 2)
def test_render_issue_without_comments(self): issue_number = self.issue_number_without_comments tag = self.tag_not_prod_or_beta # Mock the issue api_url = "{}/issues/{}".format(self.repo_api_url, issue_number) expected_issue = self._get_expected_issue(issue_number) responses.add(method=responses.GET, url=api_url, json=expected_issue) # Mock the comments list api_url = "{}/issues/{}/comments".format(self.repo_api_url, issue_number) responses.add(method=responses.GET, url=api_url, body=[], content_type="application/json") generator = self._create_generator(tag) parser = CommentingGithubIssuesParser(generator, self.title) parser.content = [issue_number] expected_render = "# {}\r\n\r\n#{}: {}".format(self.title, issue_number, expected_issue["title"]) self.assertEqual(parser.render(), expected_render) # Only 2 api calls were made, ensuring comment creation # was not attempted self.assertEqual(len(responses.calls._calls), 2)
def test_render_issue_without_prod_comment(self): issue_number = self.issue_number_without_prod_comment tag = self.tag_prod # Mock the issue api_url = '{}/issues/{}'.format( self.repo_api_url, issue_number, ) expected_issue = self._get_expected_issue(issue_number) responses.add( method=responses.GET, url=api_url, json=expected_issue, ) # Mock the comments list api_url = '{}/issues/{}/comments'.format( self.repo_api_url, issue_number, ) expected_comment_1 = self._get_expected_issue_comment( 'Some other comment', ) expected_comments = [ expected_comment_1, ] responses.add( method=responses.GET, url=api_url, body=[], content_type='application/json', ) # Mock the comment post response api_url = '{}/issues/{}/comments'.format( self.repo_api_url, issue_number, ) expected_comment_1 = self._get_expected_issue_comment('{} {}'.format( CommentingGithubIssuesParser.message_prod, self.version_number_prod, )) responses.add( method=responses.POST, url=api_url, json=expected_comment_1, ) generator = self._create_generator(tag) parser = CommentingGithubIssuesParser(generator, self.title) parser.content = [issue_number] expected_render = '# {}\r\n\r\n#{}: {}'.format( self.title, issue_number, expected_issue['title'], ) self.assertEqual(parser.render(), expected_render) # 3 api calls were made, ensuring comment creation # was attempted self.assertEqual(len(responses.calls._calls), 3)