def test_add_comment_with_no_open_issues(self): """Testing ReviewEntry.add_comment with comment not opening an issue""" self.request.user = self.review_request.submitter entry = ReviewEntry(request=self.request, review_request=self.review_request, review=self.review, collapsed=True, data=self.data) self.assertFalse(entry.has_issues) self.assertEqual(entry.issue_open_count, 0) entry.add_comment('general_comments', GeneralComment()) self.assertFalse(entry.has_issues) self.assertEqual(entry.issue_open_count, 0) self.assertTrue(entry.collapsed)
def test_add_comment_with_open_issues(self): """Testing ReviewEntry.add_comment with comment opening an issue""" entry = ReviewEntry(request=self.request, review_request=self.review_request, review=self.review, collapsed=True, data=self.data) self.assertFalse(entry.has_issues) self.assertEqual(entry.issue_open_count, 0) entry.add_comment( 'general_comments', GeneralComment(issue_opened=True, issue_status=GeneralComment.OPEN)) self.assertTrue(entry.has_issues) self.assertEqual(entry.issue_open_count, 1) self.assertTrue(entry.collapsed)
def test_get_js_model_data_with_diff_comments(self): """Testing ReviewEntry.get_js_model_data with diff comments""" self.review_request.repository = self.create_repository() diffset = self.create_diffset(self.review_request) filediff = self.create_filediff(diffset) comment1 = self.create_diff_comment(self.review, filediff) comment2 = self.create_diff_comment(self.review, filediff) self.review.publish() # This is needed by the entry's add_comment(). It's normally built when # creating the entries and their data. comment1.review_obj = self.review comment2.review_obj = self.review self.data.query_data_pre_etag() self.data.query_data_post_etag() entry = ReviewEntry(request=self.request, review_request=self.review_request, review=self.review, collapsed=False, data=self.data) entry.add_comment('diff_comments', comment1) entry.add_comment('diff_comments', comment2) self.assertEqual( entry.get_js_model_data(), { 'reviewData': { 'id': self.review.pk, 'bodyTop': 'Test Body Top', 'bodyBottom': 'Test Body Bottom', 'public': True, 'shipIt': False, }, 'diffCommentsData': [ (six.text_type(comment1.pk), six.text_type(filediff.pk)), (six.text_type(comment2.pk), six.text_type(filediff.pk)), ], })
def test_add_comment_with_open_issues_and_viewer_is_owner(self): """Testing ReviewEntry.add_comment with comment opening an issue and the review request owner is viewing the page """ self.request.user = self.review_request.submitter entry = ReviewEntry(request=self.request, review_request=self.review_request, review=self.review, collapsed=True, data=self.data) self.assertFalse(entry.has_issues) self.assertEqual(entry.issue_open_count, 0) entry.add_comment( 'general_comments', GeneralComment(issue_opened=True, issue_status=GeneralComment.OPEN)) self.assertTrue(entry.has_issues) self.assertEqual(entry.issue_open_count, 1) self.assertFalse(entry.collapsed)