def test_valid_post(self):
     kwargs = {
         'reply_content': create_content().id,
         'parent_comment': create_content().id,
     }
     response = self.api_post('/api/comment/validate_post', kwargs)
     self.assertAPISuccess(response)
    def test_replies_have_no_op_class(self):
        comment = create_comment(reply_content=create_content())
        reply = create_comment(reply_content=create_content(), parent_comment=comment)
        reply2 = create_comment(reply_content=create_content(), parent_comment=comment)
        posts = self._render_replies([reply, reply2])

        self.assertNumCssMatches(0, posts, '.op.expanded')
Exemple #3
0
 def test_valid_post(self):
     kwargs = {
         'reply_content': create_content().id,
         'parent_comment': create_content().id,
     }
     response = self.api_post('/api/comment/validate_post', kwargs)
     self.assertAPISuccess(response)
Exemple #4
0
    def after_setUp(self):
        self.user = create_user()
        self.COMMENT_COUNT = 7
        self.GROUP = create_group(name=Config['featured_groups'][0])
        self.TODAY = datetime.datetime(year=2011, month=2, day=3)

        with override_service('time', FakeTimeProvider):
            #TODO refactor into tests_helpers and consolidate w/ other tests that do this (email_channel, models)
            Services.time.t = time.mktime(self.TODAY.timetuple())

            self.comments = [
                self.post_comment(reply_content=create_content().id,
                                  category=self.GROUP.name)
                for _ in xrange(self.COMMENT_COUNT - 1)
            ]

            self.comments.append(
                self.post_comment(reply_content=create_content().id,
                                  category=self.GROUP.name,
                                  parent_comment=self.comments[-1].id))

            Services.time.step(60 * 60)

            for cmt in self.comments:
                self.api_post('/api/sticker/comment', {
                    'type_id': '1',
                    'comment_id': cmt.id
                },
                              user=create_user())
                Services.time.step()
                Services.time.step(60 * 60)
                cmt.update_score()
    def test_replying_doesnt_resurrect_post(self):
        cmt = self.post_comment(reply_content=create_content().id)
        result = self.api_post('/api/comment/delete', {'comment_id': cmt.id}, user=cmt.author)
        self.assertEqual(result, {'success': True})
        self.assertEqual(Comment.all_objects.get(id=cmt.id).visibility, Visibility.UNPUBLISHED)

        reply = self.post_comment(parent_comment=cmt.id, reply_content=create_content().id)
        self.assertEqual(Comment.all_objects.get(id=cmt.id).visibility, Visibility.UNPUBLISHED)
Exemple #6
0
    def test_details_disabled_parent_url(self):
        cmt = self.post_comment(reply_content=create_content().id)
        reply = self.post_comment(parent_comment=cmt.id, reply_content=create_content().id)
        self.assertNotEqual(cmt.details().url, None)
        self.assertEqual(reply.details().parent_url, cmt.details().url)

        cmt.moderate_and_save(Visibility.UNPUBLISHED, cmt.author)
        self.assertEqual(reply.details.force().parent_url, None)
Exemple #7
0
 def setUp(self):
     CanvasTestCase.setUp(self)
     self.group = create_group()
     self.original = create_content()
     self.op = self.post_comment(reply_content=self.original.id, category=self.group.name)
     self.remix = create_content()
     self.remix.remix_of = self.original
     self.remix.save()
Exemple #8
0
 def test_valid_post(self):
     kwargs = {
         'reply_content': create_content().id,
         'parent_comment': create_content().id,
         'external_content': dict(type="yt", start_time=100.0, end_time=200.0, source_url="1234567890"),
     }
     response = self.api_post('/api/comment/validate_post', kwargs)
     self.assertAPISuccess(response)
    def test_replies_have_no_op_class(self):
        comment = create_comment(reply_content=create_content())
        reply = create_comment(reply_content=create_content(),
                               parent_comment=comment)
        reply2 = create_comment(reply_content=create_content(),
                                parent_comment=comment)
        posts = self._render_replies([reply, reply2])

        self.assertNumCssMatches(0, posts, '.op.expanded')
Exemple #10
0
    def test_details_disabled_parent_url(self):
        cmt = self.post_comment(reply_content=create_content().id)
        reply = self.post_comment(parent_comment=cmt.id,
                                  reply_content=create_content().id)
        self.assertNotEqual(cmt.details().url, None)
        self.assertEqual(reply.details().parent_url, cmt.details().url)

        cmt.moderate_and_save(Visibility.UNPUBLISHED, cmt.author)
        self.assertEqual(reply.details.force().parent_url, None)
Exemple #11
0
 def setUp(self):
     CanvasTestCase.setUp(self)
     self.group = create_group()
     self.original = create_content()
     self.op = self.post_comment(reply_content=self.original.id,
                                 category=self.group.name)
     self.remix = create_content()
     self.remix.remix_of = self.original
     self.remix.save()
Exemple #12
0
    def test_details_repost_zero_for_different_content(self):
        content = create_content()
        cmt = create_comment(reply_content=content)

        self.assertEqual(cmt.details().repost_count, 0)

        content2 = create_content()
        cmt2 = create_comment(reply_content=content2)

        self.assertEqual(cmt.details.force().repost_count, 0)
        self.assertEqual(cmt2.details().repost_count, 0)
Exemple #13
0
    def test_details_repost_zero_for_different_content(self):
        content = create_content()
        cmt = create_comment(reply_content=content)

        self.assertEqual(cmt.details().repost_count, 0)

        content2 = create_content()
        cmt2 = create_comment(reply_content=content2)

        self.assertEqual(cmt.details.force().repost_count, 0)
        self.assertEqual(cmt2.details().repost_count, 0)
Exemple #14
0
    def test_reply_to_your_thread(self):
        def check(count):
            resp = self._get_stream()
            self.assertNumCssMatches(count, resp, '.thread_reply_activity')

        check(0)

        op = self.post_comment(reply_content=create_content().id, user=self.user)
        check(0)

        for n in xrange(1, 2):
            reply = self.post_comment(parent_comment=op.id, reply_content=create_content().id)
            check(n)
Exemple #15
0
 def test_valid_post(self):
     kwargs = {
         'reply_content':
         create_content().id,
         'parent_comment':
         create_content().id,
         'external_content':
         dict(type="yt",
              start_time=100.0,
              end_time=200.0,
              source_url="1234567890"),
     }
     response = self.api_post('/api/comment/validate_post', kwargs)
     self.assertAPISuccess(response)
Exemple #16
0
    def test_replying_doesnt_resurrect_post(self):
        cmt = self.post_comment(reply_content=create_content().id)
        result = self.api_post('/api/comment/delete', {'comment_id': cmt.id},
                               user=cmt.author)
        self.assertEqual(result, {'success': True})
        self.assertEqual(
            Comment.all_objects.get(id=cmt.id).visibility,
            Visibility.UNPUBLISHED)

        reply = self.post_comment(parent_comment=cmt.id,
                                  reply_content=create_content().id)
        self.assertEqual(
            Comment.all_objects.get(id=cmt.id).visibility,
            Visibility.UNPUBLISHED)
Exemple #17
0
    def test_at_reply(self):
        def check(count):
            resp = self._get_stream()
            self.assertNumCssMatches(count, resp, '.reply_activity')

        check(0)

        op = self.post_comment(reply_content=create_content().id, user=self.user)
        check(0)

        reply = self.post_comment(parent_comment=op.id, reply_content=create_content().id)
        check(0)

        at_reply = self.post_comment(parent_comment=op.id, reply_content=create_content().id, replied_comment=op.id)
        check(1)
Exemple #18
0
    def test_reply_to_your_thread(self):
        def check(count):
            resp = self._get_stream()
            self.assertNumCssMatches(count, resp, '.thread_reply_activity')

        check(0)

        op = self.post_comment(reply_content=create_content().id,
                               user=self.user)
        check(0)

        for n in xrange(1, 2):
            reply = self.post_comment(parent_comment=op.id,
                                      reply_content=create_content().id)
            check(n)
    def test_standard_reply(self):
        comment = create_comment(reply_content=create_content())
        post = self._render_post(comment, fullsize=False)

        self.assertNumCssMatches(1, post, '.has_content')
        self.assertNumCssMatches(0, post, '.op.expanded')
        self.assertNumCssMatches(1, post, 'div.reply_content')
Exemple #20
0
    def test_stickered_deleted_post(self):
        '''
        Checks that a deleted post is not visible in the "stickered by" view if it had been stickered before it was
        deleted.
        '''
        op = self.post_comment(reply_content=create_content().id)
        text = 'lol what'
        cmt = self.post_comment(parent_comment=op.id, reply_text=text)

        # Now another user sticks it.
        user = create_user()
        result = self.api_post('/api/sticker/comment', {
            'type_id': '1',
            'comment_id': cmt.id
        },
                               user=user)

        # Then the author deletes it.
        self.api_post('/api/comment/delete', {'comment_id': cmt.id},
                      user=cmt.author)

        # Check the user page.
        viewer = create_user()
        resp = self.get('/user/{0}/stickered'.format(user.username),
                        user=viewer)
        self.assertFalse(
            self.css_select(resp, '.image_tile.post_{0}'.format(cmt.id)))
        self.assertFalse(text in resp.content)
Exemple #21
0
    def test_replies_have_no_op_class(self):
        comment = create_comment(reply_content=create_content(), reply_text="hello friends")
        reply = create_comment(reply_text="reply!", parent_comment=comment)
        reply2 = create_comment(reply_text="another", parent_comment=comment)
        posts = self._render_replies([reply, reply2])

        self.assertNumCssMatches(0, posts, '.op.expanded')
Exemple #22
0
    def test_standard_op(self):
        comment = create_comment(reply_content=create_content(), reply_text="hello friends")
        post = self._render_post(comment, fullsize=True)

        self.assertNumCssMatches(1, post, '.has_content')
        self.assertNumCssMatches(1, post, '.op.expanded')
        self.assertNumCssMatches(1, post, 'div.reply_content')
Exemple #23
0
    def test_details_repost_one_for_repost(self):
        content = create_content()
        cmt = create_comment(reply_content=content)
        cmt2 = create_comment(reply_content=content)

        self.assertEqual(cmt.details.force().repost_count, 0)
        self.assertEqual(cmt2.details().repost_count, 1)
Exemple #24
0
    def test_replied_tells_author_and_op_author(self):
        # Some dude starts a thread
        author = create_user()
        content = create_content()
        op = create_comment(author=author, reply_content=content)

        # Another dude posts a reply
        guest_author = create_user()
        reply = create_comment(replied_comment=op, author=guest_author, parent_comment=op)
        
        self.assertEqual(reply.thread.op, op)

        # A third dude replies to the guest author
        guest_author_2 = create_user()
        reply_2 = create_comment(replied_comment=reply, author=guest_author_2, parent_comment=op)

        self.assertTrue(reply_2.thread.op.author, author)

        # Issue the action
        pn = Actions.replied(guest_author_2, reply_2)

        notifications = expander.expand(pn)
        print notifications
        # Now, we should tell both the OP author, and the guest author.
        notifications = filter(lambda n: n.channel == 'EmailChannel', notifications)
        self.assertEqual(len(notifications), 2)
        n1 = notifications[0]
        n2 = notifications[1]

        self.assertEqual(n1.action, 'replied')
        self.assertEqual(n1.recipient, guest_author)

        self.assertEqual(n2.action, 'thread_replied')
        self.assertEqual(n2.recipient, author)
Exemple #25
0
    def test_details_repost_op_isnt_curated(self):
        content = create_content()
        cmt = self.post_comment(reply_content=content.id)
        cmt2 = self.post_comment(reply_content=content.id)

        self.assertEqual(cmt.details().visibility, Visibility.PUBLIC)
        self.assertEqual(cmt2.details().visibility, Visibility.PUBLIC)
Exemple #26
0
 def after_setUp(self):
     self.inviter = create_user()
     self.invitee = create_user()
     self.comment = create_comment(
         author=self.inviter,
         reply_content=create_content(),
         category=create_group(name=MONSTER_MOBILE_GROUP))
Exemple #27
0
 def _test_rate_limit(self, user, allowed):
     with override_service('time',
                           FakeTimeProvider,
                           kwargs={'t': 1333333333.}):
         client = self.get_client(user=user)
         flag_count = min(
             freq
             for freq, timespan in knobs.FLAG_RATE_LIMITS.itervalues()) + 1
         cmts = [
             self.post_comment(reply_content=create_content().id)
             for _ in xrange(flag_count)
         ]
         msg = None
         for cmt in cmts:
             resp = self.api_post('/api/comment/flag',
                                  {'comment_id': cmt.id},
                                  client=client)
             if not resp['success']:
                 msg = resp['reason']
                 break
         getattr(self, {
             True: 'assertEqual',
             False: 'assertNotEqual'
         }[allowed])(msg, None)
         if not allowed:
             self.assertTrue('limit' in msg)
Exemple #28
0
    def test_remix(self):
        resp = self._get_stream()
        self.assertNumCssMatches(0, resp, '.remix_activity')

        original_content = create_content()
        remix_content = create_content()
        remix_content.remix_of = original_content
        remix_content.save()

        op = self.post_comment(reply_content=create_content().id)
        original = self.post_comment(parent_comment=op.id, reply_content=original_content.id, user=self.user)
        remixer = create_user()
        remix = self.post_comment(parent_comment=op.id, reply_content=remix_content.id)

        resp = self._get_stream()
        self.assertNumCssMatches(1, resp, '.remix_activity')
Exemple #29
0
    def test_details_repost_reply_is_curated(self):
        content = create_content()
        cmt = self.post_comment(reply_content=content.id)
        cmt2 = self.post_comment(reply_content=content.id, parent_comment=cmt.id)

        self.assertEqual(cmt.details().visibility, Visibility.PUBLIC)
        self.assertEqual(cmt2.details().visibility, Visibility.CURATED)
Exemple #30
0
    def test_details_repost_one_for_repost(self):
        content = create_content()
        cmt = create_comment(reply_content=content)
        cmt2 = create_comment(reply_content=content)

        self.assertEqual(cmt.details.force().repost_count, 0)
        self.assertEqual(cmt2.details().repost_count, 1)
Exemple #31
0
    def test_as_staff(self):
        group = create_group()
        user = create_staff()
        cmt = self.post_comment(reply_content=create_content().id,
                                category=group.name)
        self.assertFalse(cmt.is_offtopic())
        result = self.api_post('/api/comment/mark_offtopic', {
            'comment_id': cmt.id,
            'ot_hidden': True
        },
                               user=user)
        self.assertAPIFailure(result)
        group.moderators.add(user)
        result = self.api_post('/api/comment/mark_offtopic', {
            'comment_id': cmt.id,
            'ot_hidden': True
        },
                               user=user)
        self.assertAPISuccess(result)
        cmt = Comment.all_objects.get(pk=cmt.pk)
        self.assertTrue(cmt.is_offtopic())

        # Now undo it.
        result = self.api_post('/api/comment/mark_offtopic', {
            'comment_id': cmt.id,
            'ot_hidden': False
        },
                               user=user)
        cmt = Comment.objects.get(pk=cmt.pk)
        self.assertFalse(cmt.is_offtopic())
    def test_standard_reply(self):
        comment = create_comment(reply_content=create_content())
        post = self._render_post(comment, fullsize=False)

        self.assertNumCssMatches(1, post, '.has_content')
        self.assertNumCssMatches(0, post, '.op.expanded')
        self.assertNumCssMatches(1, post, 'div.reply_content')
Exemple #33
0
    def test_page_loads_with_feed_item(self):
        user = create_staff()
        other = create_user()
        user.follow(other)

        create_comment(author=other, reply_content=create_content())

        self.assertStatus(200, '/feed', user=user)
Exemple #34
0
    def test_standard_op(self):
        comment = create_comment(reply_content=create_content(),
                                 reply_text="hello friends")
        post = self._render_post(comment, fullsize=True)

        self.assertNumCssMatches(1, post, '.has_content')
        self.assertNumCssMatches(1, post, '.op.expanded')
        self.assertNumCssMatches(1, post, 'div.reply_content')
Exemple #35
0
 def test_details_reply_to_disabled_fails(self):
     content = create_content()
     cmt = self.post_comment(reply_content=content.id)
     cmt.moderate_and_save(Visibility.DISABLED, cmt.author)
     response = self.post_comment(fetch_comment=False,
                                  reply_text="bar",
                                  parent_comment=cmt.id)
     self.assertFalse(response['success'])
Exemple #36
0
 def test_image_post_with_reply_text(self):
     content = create_content()
     cmt, data = self._metadata(reply_text='huh', reply_content=content.id)
     self.assertEqual(data, {
         'title': data['title'],
         'description': 'huh',
         'image': data['image'],
     })
Exemple #37
0
    def test_text_reply(self):
        comment = create_comment(reply_content=create_content(), reply_text="hello friends")
        reply = create_comment(reply_text="reply!", parent_comment=comment)
        post = self._render_post(reply, fullsize=False)

        self.assertNumCssMatches(0, post, '.has_content')
        self.assertNumCssMatches(0, post, '.op.expanded')
        self.assertNumCssMatches(0, post, 'div.reply_content')
Exemple #38
0
    def test_replies_have_no_op_class(self):
        comment = create_comment(reply_content=create_content(),
                                 reply_text="hello friends")
        reply = create_comment(reply_text="reply!", parent_comment=comment)
        reply2 = create_comment(reply_text="another", parent_comment=comment)
        posts = self._render_replies([reply, reply2])

        self.assertNumCssMatches(0, posts, '.op.expanded')
Exemple #39
0
 def test_image_post_without_any_text(self):
     content = create_content()
     cmt, data = self._metadata(reply_content=content.id)
     self.assertEqual(data, {
         'title': data['title'],
         'description': knobs.TAGLINE,
         'image': data['image'],
     })
Exemple #40
0
 def test_image_post_with_reply_text(self):
     content = create_content()
     cmt, data = self._metadata(reply_text='huh', reply_content=content.id)
     self.assertEqual(data, {
         'title': data['title'],
         'description': 'huh',
         'image': data['image'],
     })
    def test_queryset_details(self):
        comments = [create_comment(reply_content=create_content()) for _ in xrange(10)]
        details1 = CachedCall.multicall([cmt.details for cmt in comments])

        queryset = Comment.objects.filter(id__in=[cmt.id for cmt in comments])
        details2 = CachedCall.queryset_details(queryset)

        self.assertEquals(details1, details2)
Exemple #42
0
    def test_text_reply(self):
        comment = create_comment(reply_content=create_content(),
                                 reply_text="hello friends")
        reply = create_comment(reply_text="reply!", parent_comment=comment)
        post = self._render_post(reply, fullsize=False)

        self.assertNumCssMatches(0, post, '.has_content')
        self.assertNumCssMatches(0, post, '.op.expanded')
        self.assertNumCssMatches(0, post, 'div.reply_content')
Exemple #43
0
    def test_actor(self):
        author = create_user()
        op = create_comment(author=author, reply_content=create_content())

        replier = create_user()
        reply = create_comment(replied_comment=op, author=replier)

        activity = ThreadReplyActivity.from_comment(replier, reply)
        self.assertEqual(activity.actor['id'], replier.id)
Exemple #44
0
    def test_actor(self):
        author = create_user()
        op = create_comment(author=author, reply_content=create_content())

        replier = create_user()
        reply = create_comment(replied_comment=op, author=replier)

        activity = ThreadReplyActivity.from_comment(replier, reply)
        self.assertEqual(activity.actor['id'], replier.id)
Exemple #45
0
 def test_deleting_others_post_fails(self):
     cmt = self.post_comment(reply_content=create_content().id)
     result = self.api_post('/api/comment/delete', {'comment_id': cmt.id})
     self.assertEqual(result, {
         'success': False,
         'reason': 'Not comment author'
     })
     self.assertEqual(
         Comment.all_objects.get(id=cmt.id).visibility, Visibility.PUBLIC)
Exemple #46
0
 def test_image_post_without_any_text(self):
     content = create_content()
     cmt, data = self._metadata(reply_content=content.id)
     self.assertEqual(
         data, {
             'title': data['title'],
             'description': knobs.TAGLINE,
             'image': data['image'],
         })
Exemple #47
0
    def test_at_reply(self):
        def check(count):
            resp = self._get_stream()
            self.assertNumCssMatches(count, resp, '.reply_activity')

        check(0)

        op = self.post_comment(reply_content=create_content().id,
                               user=self.user)
        check(0)

        reply = self.post_comment(parent_comment=op.id,
                                  reply_content=create_content().id)
        check(0)

        at_reply = self.post_comment(parent_comment=op.id,
                                     reply_content=create_content().id,
                                     replied_comment=op.id)
        check(1)
Exemple #48
0
    def test_remix(self):
        resp = self._get_stream()
        self.assertNumCssMatches(0, resp, '.remix_activity')

        original_content = create_content()
        remix_content = create_content()
        remix_content.remix_of = original_content
        remix_content.save()

        op = self.post_comment(reply_content=create_content().id)
        original = self.post_comment(parent_comment=op.id,
                                     reply_content=original_content.id,
                                     user=self.user)
        remixer = create_user()
        remix = self.post_comment(parent_comment=op.id,
                                  reply_content=remix_content.id)

        resp = self._get_stream()
        self.assertNumCssMatches(1, resp, '.remix_activity')
Exemple #49
0
    def test_details_does_not_trigger_recursion(self):
        that = self
        def test_wrapper(self, **kwargs):
            test_wrapper.calls_to_get_details += 1
            return that.old_function(self, **kwargs)

        test_wrapper.calls_to_get_details = 0

        Content._get_details = test_wrapper

        op = create_comment(reply_content=create_content())
        reply = op
        for i in range(15):
            last = reply
            reply = create_comment(parent_comment=op,
                                   reply_content=create_content(remix_of=last.reply_content))

        reply.details()
        self.assertEqual(test_wrapper.calls_to_get_details, 4)
Exemple #50
0
    def test_anonymous_actor(self):
        author = create_user()
        op = create_comment(author=author, reply_content=create_content())

        for anon in [True, False]:
            replier = create_user()
            reply = create_comment(replied_comment=op, author=replier, anonymous=anon)

            activity = ThreadReplyActivity.from_comment(replier, reply)
            self.assertEqual(activity.is_actor_anonymous, anon)
    def test_queryset_details(self):
        comments = [
            create_comment(reply_content=create_content()) for _ in xrange(10)
        ]
        details1 = CachedCall.multicall([cmt.details for cmt in comments])

        queryset = Comment.objects.filter(id__in=[cmt.id for cmt in comments])
        details2 = CachedCall.queryset_details(queryset)

        self.assertEquals(details1, details2)
Exemple #52
0
 def test_downvoted_comment(self):
     cmt = self.post_comment(reply_content=create_content().id)
     for _ in xrange(Comment.DOWNVOTES_REQUIRED):
         self.assertFalse(cmt.is_downvoted())
         self.assertFalse(cmt.is_collapsed())
         self.api_post('/api/sticker/comment', {
             'type_id': stickers.downvote.type_id,
             'comment_id': cmt.id,
         }, user=create_user())
     self.assertTrue(cmt.is_downvoted())
     self.assertTrue(cmt.is_collapsed())
Exemple #53
0
    def test_user_stickered_deleted_comment(self):
        cmt = self.post_comment(reply_content=create_content().id)

        # Now another user sticks it.
        user = create_user()
        result = self.api_post('/api/sticker/comment', {'type_id': '1', 'comment_id': cmt.id}, user=user)

        # Then the author deletes it.
        self.api_post('/api/comment/delete', {'comment_id': cmt.id}, user=cmt.author)

        stickered = get_user_stickered(user)
        self.assertEqual(len(stickered), 0)
Exemple #54
0
    def test_anonymous_actor(self):
        author = create_user()
        op = create_comment(author=author, reply_content=create_content())

        for anon in [True, False]:
            replier = create_user()
            reply = create_comment(replied_comment=op,
                                   author=replier,
                                   anonymous=anon)

            activity = ThreadReplyActivity.from_comment(replier, reply)
            self.assertEqual(activity.is_actor_anonymous, anon)
Exemple #55
0
    def test_details_repost_zero_for_audio_remix(self):
        content = create_content()
        cmt = create_comment(reply_content=content)
        cmt2 = create_comment(reply_content=content)
        external_content = ExternalContent.from_dict(dict(
            type="yt",
            end_time=10.0,
            start_time=0.0,
            source_url="123445555"
        ))
        external_content.parent_comment = cmt2
        external_content.save()

        self.assertEqual(cmt2.details().repost_count, 0)
Exemple #56
0
    def after_setUp(self):
        self.user = create_user()
        self.COMMENT_COUNT = 7
        self.GROUP = create_group(name=Config['featured_groups'][0])
        self.TODAY = datetime.datetime(year=2011, month=2, day=3)

        with override_service('time', FakeTimeProvider):
            #TODO refactor into tests_helpers and consolidate w/ other tests that do this (email_channel, models)
            Services.time.t = time.mktime(self.TODAY.timetuple())

            self.comments = [self.post_comment(reply_content=create_content().id, category=self.GROUP.name)
                            for _ in xrange(self.COMMENT_COUNT - 1)]

            self.comments.append(self.post_comment(reply_content=create_content().id, category=self.GROUP.name,
                                                   parent_comment=self.comments[-1].id))

            Services.time.step(60*60)

            for cmt in self.comments:
                self.api_post('/api/sticker/comment', {'type_id': '1', 'comment_id': cmt.id}, user=create_user())
                Services.time.step()
                Services.time.step(60*60)
                cmt.update_score()
Exemple #57
0
 def _test_rate_limit(self, user, allowed):
     with override_service('time', FakeTimeProvider, kwargs={'t': 1333333333.}):
         client = self.get_client(user=user)
         flag_count = min(freq for freq,timespan in knobs.FLAG_RATE_LIMITS.itervalues()) + 1
         cmts = [self.post_comment(reply_content=create_content().id) for _ in xrange(flag_count)]
         msg = None
         for cmt in cmts:
             resp = self.api_post('/api/comment/flag', {'comment_id': cmt.id}, client=client)
             if not resp['success']:
                 msg = resp['reason']
                 break
         getattr(self, {True: 'assertEqual', False: 'assertNotEqual'}[allowed])(msg, None)
         if not allowed:
             self.assertTrue('limit' in msg)
Exemple #58
0
 def _make_stickers(self, sticks=['smiley', 'banana', 'frowny', 'frowny'], top='banana', per=2):
     self.top_id = stickers.get(top).type_id
     self.stickers = map(stickers.get, sticks)
     self.cmt = self.post_comment(reply_content=create_content().id)
     from canvas import economy
     for sticker in self.stickers:
         for _ in xrange(per):
             user = create_rich_user()
             if sticker.cost:
                 user.kv.stickers.add_limited_sticker(sticker)
                 economy.purchase_stickers(user, sticker.type_id, 1)
                 #user.redis.user_kv.hset('sticker:%s:count' % STORE_ITEM, 1)
             self.api_post('/api/sticker/comment', {
                 'type_id': sticker.type_id,
                 'comment_id': self.cmt.id,
             }, user=user)