示例#1
0
    def test_handle_follow_local_manually_approves(self, *_):
        """send a follow request"""
        with patch(
                "bookwyrm.suggested_users.rerank_suggestions_task.delay"
        ), patch("bookwyrm.activitystreams.populate_stream_task.delay"), patch(
                "bookwyrm.lists_stream.populate_lists_task.delay"):
            rat = models.User.objects.create_user(
                "*****@*****.**",
                "*****@*****.**",
                "ratword",
                local=True,
                localname="rat",
                remote_id="https://example.com/users/rat",
                manually_approves_followers=True,
            )
        request = self.factory.post("", {"user": rat})
        request.user = self.local_user
        self.assertEqual(models.UserFollowRequest.objects.count(), 0)

        with patch(
                "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
        ):
            views.follow(request)
        rel = models.UserFollowRequest.objects.get()

        self.assertEqual(rel.user_subject, self.local_user)
        self.assertEqual(rel.user_object, rat)
        self.assertEqual(rel.status, "follow_request")
示例#2
0
    def test_handle_follow_remote(self):
        ''' send a follow request '''
        request = self.factory.post('', {'user': self.remote_user.username})
        request.user = self.local_user
        self.assertEqual(models.UserFollowRequest.objects.count(), 0)

        with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
            views.follow(request)

        rel = models.UserFollowRequest.objects.get()

        self.assertEqual(rel.user_subject, self.local_user)
        self.assertEqual(rel.user_object, self.remote_user)
        self.assertEqual(rel.status, 'follow_request')
示例#3
0
    def test_handle_follow_remote(self, *_):
        """send a follow request"""
        request = self.factory.post("", {"user": self.remote_user.username})
        request.user = self.local_user
        self.assertEqual(models.UserFollowRequest.objects.count(), 0)

        with patch(
                "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
        ):
            views.follow(request)

        rel = models.UserFollowRequest.objects.get()

        self.assertEqual(rel.user_subject, self.local_user)
        self.assertEqual(rel.user_object, self.remote_user)
        self.assertEqual(rel.status, "follow_request")
示例#4
0
    def test_handle_follow_local(self):
        ''' send a follow request '''
        rat = models.User.objects.create_user(
            '*****@*****.**',
            '*****@*****.**',
            'ratword',
            local=True,
            localname='rat',
            remote_id='https://example.com/users/rat',
        )
        request = self.factory.post('', {'user': rat})
        request.user = self.local_user
        self.assertEqual(models.UserFollowRequest.objects.count(), 0)

        with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
            views.follow(request)

        rel = models.UserFollows.objects.get()

        self.assertEqual(rel.user_subject, self.local_user)
        self.assertEqual(rel.user_object, rat)
        self.assertEqual(rel.status, 'follows')
示例#5
0
    def test_handle_follow_local(self):
        """ send a follow request """
        rat = models.User.objects.create_user(
            "*****@*****.**",
            "*****@*****.**",
            "ratword",
            local=True,
            localname="rat",
            remote_id="https://example.com/users/rat",
        )
        request = self.factory.post("", {"user": rat})
        request.user = self.local_user
        self.assertEqual(models.UserFollowRequest.objects.count(), 0)

        with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
            views.follow(request)

        rel = models.UserFollows.objects.get()

        self.assertEqual(rel.user_subject, self.local_user)
        self.assertEqual(rel.user_object, rat)
        self.assertEqual(rel.status, "follows")