forked from mirrors/bookwyrm
Sets mocks up for incoming tests
This commit is contained in:
parent
9c6db1cc0e
commit
b1640c5dc9
4 changed files with 41 additions and 30 deletions
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import pathlib
|
||||
from unittest.mock import patch
|
||||
from django.test import TestCase
|
||||
|
||||
from bookwyrm import models, incoming
|
||||
|
@ -7,15 +8,17 @@ from bookwyrm import models, incoming
|
|||
|
||||
class Favorite(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',
|
||||
)
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
with patch('bookwyrm.models.user.get_remote_reviews.delay'):
|
||||
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',
|
||||
'mouse', 'mouse@mouse.com', 'mouseword', local=True,
|
||||
remote_id='http://local.com/user/mouse')
|
||||
|
||||
self.status = models.Status.objects.create(
|
||||
|
|
|
@ -6,15 +6,17 @@ from bookwyrm import models, incoming
|
|||
|
||||
class IncomingFollow(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',
|
||||
)
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
with patch('bookwyrm.models.user.get_remote_reviews.delay'):
|
||||
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')
|
||||
'mouse', 'mouse@mouse.com', 'mouseword', local=True)
|
||||
self.local_user.remote_id = 'http://local.com/user/mouse'
|
||||
self.local_user.save()
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from unittest.mock import patch
|
||||
from django.test import TestCase
|
||||
|
||||
from bookwyrm import models, incoming
|
||||
|
@ -5,15 +6,17 @@ from bookwyrm import models, incoming
|
|||
|
||||
class IncomingFollowAccept(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',
|
||||
)
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
with patch('bookwyrm.models.user.get_remote_reviews.delay'):
|
||||
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')
|
||||
'mouse', 'mouse@mouse.com', 'mouseword', local=True)
|
||||
self.local_user.remote_id = 'http://local.com/user/mouse'
|
||||
self.local_user.save()
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
''' when a remote user changes their profile '''
|
||||
import json
|
||||
import pathlib
|
||||
from unittest.mock import patch
|
||||
from django.test import TestCase
|
||||
|
||||
from bookwyrm import models, incoming
|
||||
|
@ -8,12 +9,14 @@ from bookwyrm import models, incoming
|
|||
|
||||
class UpdateUser(TestCase):
|
||||
def setUp(self):
|
||||
self.user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.com', 'mouseword',
|
||||
remote_id='https://example.com/user/mouse',
|
||||
local=False,
|
||||
localname='mouse'
|
||||
)
|
||||
with patch('bookwyrm.models.user.set_remote_server.delay'):
|
||||
with patch('bookwyrm.models.user.get_remote_reviews.delay'):
|
||||
self.user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.com', 'mouseword',
|
||||
remote_id='https://example.com/user/mouse',
|
||||
local=False,
|
||||
localname='mouse'
|
||||
)
|
||||
|
||||
datafile = pathlib.Path(__file__).parent.joinpath(
|
||||
'../data/ap_user.json'
|
||||
|
|
Loading…
Reference in a new issue