mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-04 15:26:48 +00:00
Adds more incoming follow test cases
This commit is contained in:
parent
db18014325
commit
2d2863d4a8
1 changed files with 48 additions and 1 deletions
|
@ -44,4 +44,51 @@ class Follow(TestCase):
|
||||||
follow = models.UserFollows.objects.get(user_object=self.local_user)
|
follow = models.UserFollows.objects.get(user_object=self.local_user)
|
||||||
self.assertEqual(follow.user_subject, self.remote_user)
|
self.assertEqual(follow.user_subject, self.remote_user)
|
||||||
|
|
||||||
# an Accept should be sent out
|
|
||||||
|
def test_handle_follow_manually_approved(self):
|
||||||
|
activity = {
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
"id": "https://example.com/users/rat/follows/123",
|
||||||
|
"type": "Follow",
|
||||||
|
"actor": "https://example.com/users/rat",
|
||||||
|
"object": "http://local.com/user/mouse"
|
||||||
|
}
|
||||||
|
|
||||||
|
self.local_user.manually_approves_followers = True
|
||||||
|
self.local_user.save()
|
||||||
|
|
||||||
|
incoming.handle_follow(activity)
|
||||||
|
|
||||||
|
# notification created
|
||||||
|
notification = models.Notification.objects.get()
|
||||||
|
self.assertEqual(notification.user, self.local_user)
|
||||||
|
self.assertEqual(notification.notification_type, 'FOLLOW_REQUEST')
|
||||||
|
|
||||||
|
# the request should exist
|
||||||
|
request = models.UserFollowRequest.objects.get()
|
||||||
|
self.assertEqual(request.user_subject, self.remote_user)
|
||||||
|
self.assertEqual(request.user_object, self.local_user)
|
||||||
|
|
||||||
|
# the follow relationship should not exist
|
||||||
|
follow = models.UserFollows.objects.all()
|
||||||
|
self.assertEqual(list(follow), [])
|
||||||
|
|
||||||
|
|
||||||
|
def test_nonexistent_user_follow(self):
|
||||||
|
activity = {
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
"id": "https://example.com/users/rat/follows/123",
|
||||||
|
"type": "Follow",
|
||||||
|
"actor": "https://example.com/users/rat",
|
||||||
|
"object": "http://local.com/user/nonexistent-user"
|
||||||
|
}
|
||||||
|
|
||||||
|
incoming.handle_follow(activity)
|
||||||
|
|
||||||
|
# do nothing
|
||||||
|
notifications = models.Notification.objects.all()
|
||||||
|
self.assertEqual(list(notifications), [])
|
||||||
|
requests = models.UserFollowRequest.objects.all()
|
||||||
|
self.assertEqual(list(requests), [])
|
||||||
|
follows = models.UserFollows.objects.all()
|
||||||
|
self.assertEqual(list(follows), [])
|
||||||
|
|
Loading…
Reference in a new issue