forked from mirrors/bookwyrm
Test fixes
This commit is contained in:
parent
bbbfbe721e
commit
646ced80ce
7 changed files with 29 additions and 36 deletions
|
@ -15,7 +15,7 @@ class BaseModel(TestCase):
|
|||
|
||||
def test_remote_id_with_user(self):
|
||||
user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.com', 'mouseword')
|
||||
'mouse', 'mouse@mouse.com', 'mouseword', local=True)
|
||||
instance = BookWyrmModel()
|
||||
instance.user = user
|
||||
instance.id = 1
|
||||
|
|
|
@ -24,7 +24,7 @@ class Book(TestCase):
|
|||
def test_remote_id(self):
|
||||
remote_id = 'https://%s/book/%d' % (settings.DOMAIN, self.work.id)
|
||||
self.assertEqual(self.work.get_remote_id(), remote_id)
|
||||
self.assertEqual(self.work.remote_id, 'https://example.com/book/1')
|
||||
self.assertEqual(self.work.remote_id, remote_id)
|
||||
|
||||
def test_create_book(self):
|
||||
''' you shouldn't be able to create Books (only editions and works) '''
|
||||
|
@ -59,7 +59,7 @@ class Book(TestCase):
|
|||
class Shelf(TestCase):
|
||||
def setUp(self):
|
||||
user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword')
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
|
||||
models.Shelf.objects.create(
|
||||
name='Test Shelf', identifier='test-shelf', user=user)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class ImportJob(TestCase):
|
|||
unknown_read_data['Date Read'] = ''
|
||||
|
||||
user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword')
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
|
||||
job = models.ImportJob.objects.create(user=user)
|
||||
models.ImportItem.objects.create(
|
||||
job=job, index=1, data=currently_reading_data)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
''' testing models '''
|
||||
from unittest.mock import patch
|
||||
from django.test import TestCase
|
||||
|
||||
from bookwyrm import models
|
||||
|
@ -6,15 +7,16 @@ from bookwyrm import models
|
|||
|
||||
class Relationship(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'):
|
||||
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()
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from bookwyrm import models, settings
|
|||
class Status(TestCase):
|
||||
def setUp(self):
|
||||
user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword')
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
|
||||
book = models.Edition.objects.create(title='Example Edition')
|
||||
|
||||
models.Status.objects.create(user=user, content='Blah blah')
|
||||
|
@ -40,13 +40,3 @@ class Status(TestCase):
|
|||
expected_id = 'https://%s/user/mouse/review/%d' % \
|
||||
(settings.DOMAIN, review.id)
|
||||
self.assertEqual(review.remote_id, expected_id)
|
||||
|
||||
|
||||
class Tag(TestCase):
|
||||
def test_tag(self):
|
||||
book = models.Edition.objects.create(title='Example Edition')
|
||||
user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword')
|
||||
tag = models.Tag.objects.create(user=user, book=book, name='t/est tag')
|
||||
self.assertEqual(tag.identifier, 't%2Fest+tag')
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from bookwyrm.settings import DOMAIN
|
|||
class User(TestCase):
|
||||
def setUp(self):
|
||||
self.user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword')
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
|
||||
|
||||
def test_computed_fields(self):
|
||||
''' username instead of id here '''
|
||||
|
@ -53,7 +53,6 @@ class User(TestCase):
|
|||
self.assertEqual(activity['name'], self.user.name)
|
||||
self.assertEqual(activity['inbox'], self.user.inbox)
|
||||
self.assertEqual(activity['outbox'], self.user.outbox)
|
||||
self.assertEqual(activity['followers'], self.user.ap_followers)
|
||||
self.assertEqual(activity['bookwyrmUser'], True)
|
||||
self.assertEqual(activity['discoverable'], True)
|
||||
self.assertEqual(activity['type'], 'Person')
|
||||
|
|
|
@ -2,17 +2,19 @@ from unittest.mock import patch
|
|||
from django.test import TestCase
|
||||
|
||||
from bookwyrm import models, outgoing
|
||||
from bookwyrm.settings import DOMAIN
|
||||
|
||||
|
||||
class Following(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'):
|
||||
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,
|
||||
|
@ -23,7 +25,7 @@ class Following(TestCase):
|
|||
def test_handle_follow(self):
|
||||
self.assertEqual(models.UserFollowRequest.objects.count(), 0)
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
outgoing.handle_follow(self.local_user, self.remote_user)
|
||||
|
||||
rel = models.UserFollowRequest.objects.get()
|
||||
|
@ -36,7 +38,7 @@ class Following(TestCase):
|
|||
def test_handle_unfollow(self):
|
||||
self.remote_user.followers.add(self.local_user)
|
||||
self.assertEqual(self.remote_user.followers.count(), 1)
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
outgoing.handle_unfollow(self.local_user, self.remote_user)
|
||||
|
||||
self.assertEqual(self.remote_user.followers.count(), 0)
|
||||
|
@ -49,7 +51,7 @@ class Following(TestCase):
|
|||
)
|
||||
rel_id = rel.id
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
outgoing.handle_accept(rel)
|
||||
# request should be deleted
|
||||
self.assertEqual(
|
||||
|
@ -66,7 +68,7 @@ class Following(TestCase):
|
|||
)
|
||||
rel_id = rel.id
|
||||
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay') as _:
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
outgoing.handle_reject(rel)
|
||||
# request should be deleted
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Reference in a new issue