コード例 #1
0
    def test_can_like_post_same_user(self, get_scores, is_free):
        user = Generators.user()
        post = Generators.forum_post(user=user)

        is_free.return_value = False

        self.assertFalse(UserService(user).can_like(post))
コード例 #2
0
ファイル: test_forum.py プロジェクト: pierfra-r/astrobin
    def test_save_existing_on_moderation_notifications(self, push_notification,
                                                       get_mentions):
        mentioned = Generators.user()

        get_mentions.return_value = [mentioned]

        post = Generators.forum_post(on_moderation=True)

        push_notification.reset_mock()
        get_mentions.reset_mock()

        post.body = "foo"
        post.save()

        with self.assertRaises(AssertionError):
            push_notification.assert_called_with([mentioned], post.user,
                                                 'new_forum_post_mention',
                                                 mock.ANY)

        with self.assertRaises(AssertionError):
            push_notification.assert_called_with(mock.ANY, post.user,
                                                 'new_forum_reply', mock.ANY)

        with self.assertRaises(AssertionError):
            push_notification.assert_called_with([post.user], None,
                                                 'forum_post_approved',
                                                 mock.ANY)
コード例 #3
0
    def test_can_like_post_ok(self, get_scores, is_free):
        get_scores.return_value = {'user_scores_index': 0}
        is_free.return_value = False

        user = Generators.user()
        post = Generators.forum_post()

        self.assertTrue(UserService(user).can_like(post))
コード例 #4
0
    def test_can_like_post_closed_topic(self, get_scores, is_free):
        user = Generators.user()
        post = Generators.forum_post()

        post.topic.closed = True
        post.topic.save()

        is_free.return_value = False

        self.assertFalse(UserService(user).can_like(post))
コード例 #5
0
    def test_send_moderation_required_notification_non_image_target(
            self, push_notification):
        post = Generators.forum_post()
        comment = NestedCommentsGenerators.comment(target=post,
                                                   pending_moderation=True)

        push_notification.reset_mock()

        CommentNotificationsService(
            comment).send_moderation_required_notification()

        with self.assertRaises(AssertionError):
            push_notification.assert_called_with(
                [post.user], None, 'new_image_comment_moderation', mock.ANY)
コード例 #6
0
ファイル: test_forum.py プロジェクト: pierfra-r/astrobin
    def test_save_new_notifications(self, push_notification, get_mentions):
        mentioned = Generators.user()

        get_mentions.return_value = [mentioned]

        post = Generators.forum_post()

        push_notification.assert_has_calls([
            mock.call([mentioned], post.user, 'new_forum_post_mention',
                      mock.ANY),
        ],
                                           any_order=True)

        with self.assertRaises(AssertionError):
            push_notification.assert_called_with(mock.ANY, post.user,
                                                 'new_forum_reply', mock.ANY)

        with self.assertRaises(AssertionError):
            push_notification.assert_called_with([post.user], None,
                                                 'forum_post_approved',
                                                 mock.ANY)