コード例 #1
0
    def test_get_url(self):
        from comment.tests.base import RequestFactory

        factory = RequestFactory()
        request = factory.get('/')
        request.user = self.user_1
        attr = 'COMMENT_PER_PAGE'
        comment = self.parent_comment_3

        # no pagination(parent comment 3, 2, 1 belong to the same content_object_1)
        with patch.object(settings, attr, 0):
            comment_url = comment.content_object.get_absolute_url(
            ) + '#' + comment.urlhash

            self.assertEqual(comment_url, comment.get_url(request))

        # with pagination
        with patch.object(settings, attr, 3):
            # comment on first page
            self.assertEqual(comment_url, comment.get_url(request))

            # comment on the second page
            comment = self.parent_comment_1
            comment_url = comment.content_object.get_absolute_url(
            ) + '?page=2' + '#' + comment.urlhash
            self.assertEqual(comment_url, comment.get_url(request))
コード例 #2
0
ファイル: test_utils.py プロジェクト: JAYBLA/sogea
    def setUp(self):
        super().setUp()
        self.time_posted = timezone.now()
        _email = '*****@*****.**'
        _content = 'posting anonymous comment'
        _parent = None
        _factory = RequestFactory()
        self.comment_obj = Comment(content_object=self.post_1,
                                   content=_content,
                                   user=None,
                                   parent=_parent,
                                   email=_email,
                                   posted=self.time_posted)

        self.key = signing.dumps(self.comment_obj.to_dict(), compress=True)
        self.request = _factory.get('/')
コード例 #3
0
 def setUp(self):
     super().setUp()
     factory = RequestFactory()
     self.request = factory.get('/')
コード例 #4
0
ファイル: test_comments.py プロジェクト: Radi85/Comment
 def setUpTestData(cls):
     super().setUpTestData()
     cls.request = RequestFactory().get('/')
     cls.request.user = cls.user_1