Esempio n. 1
0
    def test_get_js_model_data(self):
        """Testing ReviewEntry.get_js_model_data"""
        self.review.ship_it = True
        self.review.publish()

        entry = ReviewEntry(request=self.request,
                            review_request=self.review_request,
                            review=self.review,
                            collapsed=False,
                            data=self.data)

        self.assertEqual(
            entry.get_js_model_data(), {
                'reviewData': {
                    'id': self.review.pk,
                    'bodyTop': 'Test Body Top',
                    'bodyBottom': 'Test Body Bottom',
                    'public': True,
                    'shipIt': True,
                },
            })
Esempio n. 2
0
    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)),
                ],
            })