Exemple #1
0
 def test_extra_css_classes_visibility(self):
     author = self.factory.makePerson()
     comment = self.factory.makeCodeReviewComment(sender=author)
     display_comment = CodeReviewDisplayComment(comment)
     self.assertEqual('', display_comment.extra_css_class)
     with person_logged_in(author):
         display_comment.message.setVisible(False)
     self.assertEqual('adminHiddenComment', display_comment.extra_css_class)
    def test_display_comment_provides_icodereviewdisplaycomment(self):
        # The CodeReviewDisplayComment class provides IComment.
        with person_logged_in(self.factory.makePerson()):
            comment = self.factory.makeCodeReviewComment()

        display_comment = CodeReviewDisplayComment(comment)

        verifyObject(ICodeReviewDisplayComment, display_comment)
Exemple #3
0
 def test_no_footer_for_non_mergeable_and_non_admin(self):
     """A mortal sees no footer for a comment on a non-mergeable MP."""
     comment = self.makeCodeReviewComment()
     merge_proposal = comment.branch_merge_proposal
     with person_logged_in(merge_proposal.registrant):
         merge_proposal.markAsMerged(
             merge_reporter=merge_proposal.registrant)
     display_comment = CodeReviewDisplayComment(comment)
     browser = self.getViewBrowser(display_comment)
     footer = Tag('comment footer', 'div', {'class': 'boardCommentFooter'})
     self.assertThat(browser.contents, Not(HTMLContains(footer)))
Exemple #4
0
 def test_footer_for_mergeable_and_non_admin(self):
     """A mortal sees a Reply link for a comment on a mergeable MP."""
     comment = self.makeCodeReviewComment()
     display_comment = CodeReviewDisplayComment(comment)
     browser = self.getViewBrowser(display_comment)
     footer = Tag('comment footer', 'div', {'class': 'boardCommentFooter'})
     hide_link = Tag('hide link', 'a', text=re.compile(r'\s*Hide\s*'))
     reply_link = Tag('reply link', 'a', text='Reply')
     self.assertThat(browser.contents, Not(HTMLContains(hide_link)))
     self.assertThat(browser.contents,
                     HTMLContains(reply_link.within(footer)))
    def test_comment_page_has_meta_description(self):
        # The CodeReviewDisplayComment class provides IComment.
        with person_logged_in(self.factory.makePerson()):
            comment = self.factory.makeCodeReviewComment()

        display_comment = CodeReviewDisplayComment(comment)
        browser = self.getViewBrowser(display_comment)
        self.assertThat(
            browser.contents,
            HTMLContains(
                Tag('meta description', 'meta',
                    dict(name='description', content=comment.message_body))))
Exemple #6
0
 def test_display_comment_inline_comment(self):
     # The CodeReviewDisplayComment links to related inline comments
     # when they exist.
     person = self.factory.makePerson()
     with person_logged_in(person):
         comment = self.factory.makeCodeReviewComment()
     # `CodeReviewDisplayComment.previewdiff_id` is None if there
     # is no related inline-comments.
     display_comment = CodeReviewDisplayComment(comment)
     self.assertIsNone(display_comment.previewdiff_id)
     # Create a `PreviewDiff` and add inline-comments in
     # the context of this review comment.
     with person_logged_in(person):
         previewdiff = self.factory.makePreviewDiff()
         self.makeInlineComment(person, comment, previewdiff)
     # 'previewdiff_id' property is cached, so its value did not
     # change on the existing object.
     self.assertIsNone(display_comment.previewdiff_id)
     # On a new object, it successfully returns the `PreviewDiff.id`
     # containing inline-comments related with this review comment.
     display_comment = CodeReviewDisplayComment(comment)
     self.assertEqual(previewdiff.id, display_comment.previewdiff_id)
Exemple #7
0
 def test_footer_for_non_mergeable_and_admin(self):
     """An admin sees a Hide link for a comment on a non-mergeable MP."""
     comment = self.makeCodeReviewComment()
     merge_proposal = comment.branch_merge_proposal
     with person_logged_in(merge_proposal.registrant):
         merge_proposal.markAsMerged(
             merge_reporter=merge_proposal.registrant)
     display_comment = CodeReviewDisplayComment(comment)
     browser = self.getViewBrowser(display_comment,
                                   user=self.factory.makeAdministrator())
     footer = Tag('comment footer', 'div', {'class': 'boardCommentFooter'})
     hide_link = Tag('hide link', 'a', text=re.compile(r'\s*Hide\s*'))
     reply_link = Tag('reply link', 'a', text='Reply')
     self.assertThat(browser.contents,
                     HTMLContains(hide_link.within(footer)))
     self.assertThat(browser.contents, Not(HTMLContains(reply_link)))
Exemple #8
0
 def test_show_spam_controls_permissions(self):
     # Admins, registry experts, and the author of the comment itself can
     # hide comments, but other people can't.
     author = self.factory.makePerson()
     comment = self.factory.makeCodeReviewComment(sender=author)
     display_comment = CodeReviewDisplayComment(comment)
     with person_logged_in(author):
         self.assertTrue(display_comment.show_spam_controls)
     clear_property_cache(display_comment)
     with person_logged_in(self.factory.makePerson()):
         self.assertFalse(display_comment.show_spam_controls)
     clear_property_cache(display_comment)
     with celebrity_logged_in('registry_experts'):
         self.assertTrue(display_comment.show_spam_controls)
     clear_property_cache(display_comment)
     with admin_logged_in():
         self.assertTrue(display_comment.show_spam_controls)