mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 05:21:08 +00:00
reorganize incoming/outgoing tests
This commit is contained in:
parent
cae7bbf834
commit
694de44f3f
6 changed files with 41 additions and 7 deletions
1
bookwyrm/tests/incoming/__init__.py
Normal file
1
bookwyrm/tests/incoming/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
from . import *
|
|
@ -6,7 +6,6 @@ from bookwyrm import models, incoming
|
||||||
|
|
||||||
|
|
||||||
class Favorite(TestCase):
|
class Favorite(TestCase):
|
||||||
''' not too much going on in the books model but here we are '''
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
'rat', 'rat@rat.com', 'ratword',
|
'rat', 'rat@rat.com', 'ratword',
|
||||||
|
@ -25,7 +24,7 @@ class Favorite(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath(
|
datafile = pathlib.Path(__file__).parent.joinpath(
|
||||||
'data/ap_user.json'
|
'../data/ap_user.json'
|
||||||
)
|
)
|
||||||
self.user_data = json.loads(datafile.read_bytes())
|
self.user_data = json.loads(datafile.read_bytes())
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import json
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from bookwyrm import models, incoming
|
from bookwyrm import models, incoming
|
||||||
|
|
||||||
|
|
||||||
class Follow(TestCase):
|
class IncomingFollow(TestCase):
|
||||||
''' not too much going on in the books model but here we are '''
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
'rat', 'rat@rat.com', 'ratword',
|
'rat', 'rat@rat.com', 'ratword',
|
|
@ -1,11 +1,9 @@
|
||||||
import json
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from bookwyrm import models, incoming
|
from bookwyrm import models, incoming
|
||||||
|
|
||||||
|
|
||||||
class IncomingFollowAccept(TestCase):
|
class IncomingFollowAccept(TestCase):
|
||||||
''' not too much going on in the books model but here we are '''
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
'rat', 'rat@rat.com', 'ratword',
|
'rat', 'rat@rat.com', 'ratword',
|
1
bookwyrm/tests/outgoing/__init__.py
Normal file
1
bookwyrm/tests/outgoing/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
from . import *
|
37
bookwyrm/tests/outgoing/test_follow.py
Normal file
37
bookwyrm/tests/outgoing/test_follow.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from bookwyrm import models, outgoing
|
||||||
|
|
||||||
|
|
||||||
|
class OutgoingFollow(TestCase):
|
||||||
|
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',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
Loading…
Reference in a new issue