2020-10-16 21:04:06 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
|
|
|
|
from bookwyrm import models, outgoing
|
|
|
|
|
|
|
|
|
2020-10-16 21:14:07 +00:00
|
|
|
class Following(TestCase):
|
2020-10-16 21:04:06 +00:00
|
|
|
def setUp(self):
|
|
|
|
self.remote_user = models.User.objects.create_user(
|
|
|
|
'rat', 'rat@rat.com', 'ratword',
|
|
|
|
local=False,
|
|
|
|
remote_id='https://example.com/users/rat',
|
|
|
|
inbox='https://example.com/users/rat/inbox',
|
|
|
|
outbox='https://example.com/users/rat/outbox',
|
|
|
|
)
|
|
|
|
self.local_user = models.User.objects.create_user(
|
|
|
|
'mouse', 'mouse@mouse.com', 'mouseword',
|
|
|
|
local=True,
|
|
|
|
remote_id='http://local.com/users/mouse',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-11-27 19:53:30 +00:00
|
|
|
# def test_handle_follow(self):
|
|
|
|
# self.assertEqual(models.UserFollowRequest.objects.count(), 0)
|
|
|
|
#
|
|
|
|
# outgoing.handle_follow(self.local_user, self.remote_user)
|
|
|
|
# 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')
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# def test_handle_unfollow(self):
|
|
|
|
# self.remote_user.followers.add(self.local_user)
|
|
|
|
# self.assertEqual(self.remote_user.followers.count(), 1)
|
|
|
|
# outgoing.handle_unfollow(self.local_user, self.remote_user)
|
|
|
|
#
|
|
|
|
# self.assertEqual(self.remote_user.followers.count(), 0)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# def test_handle_accept(self):
|
|
|
|
# rel = models.UserFollowRequest.objects.create(
|
|
|
|
# user_subject=self.local_user,
|
|
|
|
# user_object=self.remote_user
|
|
|
|
# )
|
|
|
|
# rel_id = rel.id
|
|
|
|
#
|
|
|
|
# outgoing.handle_accept(rel)
|
|
|
|
# # request should be deleted
|
|
|
|
# self.assertEqual(
|
|
|
|
# models.UserFollowRequest.objects.filter(id=rel_id).count(), 0
|
|
|
|
# )
|
|
|
|
# # follow relationship should exist
|
|
|
|
# self.assertEqual(self.remote_user.followers.first(), self.local_user)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# def test_handle_reject(self):
|
|
|
|
# rel = models.UserFollowRequest.objects.create(
|
|
|
|
# user_subject=self.local_user,
|
|
|
|
# user_object=self.remote_user
|
|
|
|
# )
|
|
|
|
# rel_id = rel.id
|
|
|
|
#
|
|
|
|
# outgoing.handle_reject(rel)
|
|
|
|
# # request should be deleted
|
|
|
|
# self.assertEqual(
|
|
|
|
# models.UserFollowRequest.objects.filter(id=rel_id).count(), 0
|
|
|
|
# )
|
|
|
|
# # follow relationship should not exist
|
|
|
|
# self.assertEqual(
|
|
|
|
# models.UserFollows.objects.filter(id=rel_id).count(), 0
|
|
|
|
# )
|