mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 12:01:14 +00:00
Fix tests
This commit is contained in:
parent
b8bff8a882
commit
b7965ce2ae
31 changed files with 380 additions and 367 deletions
|
@ -20,8 +20,9 @@ class Person(TestCase):
|
||||||
|
|
||||||
def test_user_to_model(self):
|
def test_user_to_model(self):
|
||||||
activity = activitypub.Person(**self.user_data)
|
activity = activitypub.Person(**self.user_data)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
user = activity.to_model(model=models.User)
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
|
user = activity.to_model(model=models.User)
|
||||||
self.assertEqual(user.username, "mouse@example.com")
|
self.assertEqual(user.username, "mouse@example.com")
|
||||||
self.assertEqual(user.remote_id, "https://example.com/user/mouse")
|
self.assertEqual(user.remote_id, "https://example.com/user/mouse")
|
||||||
self.assertFalse(user.local)
|
self.assertFalse(user.local)
|
||||||
|
|
|
@ -12,16 +12,17 @@ class Quotation(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""model objects we'll need"""
|
"""model objects we'll need"""
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
self.user = models.User.objects.create_user(
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
"mouse",
|
self.user = models.User.objects.create_user(
|
||||||
"mouse@mouse.mouse",
|
"mouse",
|
||||||
"mouseword",
|
"mouse@mouse.mouse",
|
||||||
local=False,
|
"mouseword",
|
||||||
inbox="https://example.com/user/mouse/inbox",
|
local=False,
|
||||||
outbox="https://example.com/user/mouse/outbox",
|
inbox="https://example.com/user/mouse/inbox",
|
||||||
remote_id="https://example.com/user/mouse",
|
outbox="https://example.com/user/mouse/outbox",
|
||||||
)
|
remote_id="https://example.com/user/mouse",
|
||||||
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
|
|
@ -82,7 +82,7 @@ class SelfConnector(TestCase):
|
||||||
|
|
||||||
def test_search_multiple_editions(self):
|
def test_search_multiple_editions(self):
|
||||||
"""it should get rid of duplicate editions for the same work"""
|
"""it should get rid of duplicate editions for the same work"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
work = models.Work.objects.create(title="Work Title")
|
work = models.Work.objects.create(title="Work Title")
|
||||||
edition_1 = models.Edition.objects.create(
|
edition_1 = models.Edition.objects.create(
|
||||||
title="Edition 1 Title", parent_work=work
|
title="Edition 1 Title", parent_work=work
|
||||||
|
|
|
@ -23,16 +23,16 @@ class Activitystreams(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="nutria",
|
localname="nutria",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.book = models.Edition.objects.create(title="test book")
|
self.book = models.Edition.objects.create(title="test book")
|
||||||
|
|
||||||
|
|
|
@ -25,16 +25,16 @@ class ActivitypubMixins(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "http://example.com/a/b"
|
self.local_user.remote_id = "http://example.com/a/b"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.object_mock = {
|
self.object_mock = {
|
||||||
"to": "to field",
|
"to": "to field",
|
||||||
|
@ -143,16 +143,17 @@ class ActivitypubMixins(TestCase):
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
self.local_user.followers.add(self.remote_user)
|
self.local_user.followers.add(self.remote_user)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
another_remote_user = models.User.objects.create_user(
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
"nutria",
|
another_remote_user = models.User.objects.create_user(
|
||||||
"nutria@nutria.com",
|
"nutria",
|
||||||
"nutriaword",
|
"nutria@nutria.com",
|
||||||
local=False,
|
"nutriaword",
|
||||||
remote_id="https://example.com/users/nutria",
|
local=False,
|
||||||
inbox="https://example.com/users/nutria/inbox",
|
remote_id="https://example.com/users/nutria",
|
||||||
outbox="https://example.com/users/nutria/outbox",
|
inbox="https://example.com/users/nutria/inbox",
|
||||||
)
|
outbox="https://example.com/users/nutria/outbox",
|
||||||
|
)
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user", "recipients"))
|
MockSelf = namedtuple("Self", ("privacy", "user", "recipients"))
|
||||||
mock_self = MockSelf("public", self.local_user, [another_remote_user])
|
mock_self = MockSelf("public", self.local_user, [another_remote_user])
|
||||||
|
|
||||||
|
@ -166,16 +167,17 @@ class ActivitypubMixins(TestCase):
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
self.local_user.followers.add(self.remote_user)
|
self.local_user.followers.add(self.remote_user)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
another_remote_user = models.User.objects.create_user(
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
"nutria",
|
another_remote_user = models.User.objects.create_user(
|
||||||
"nutria@nutria.com",
|
"nutria",
|
||||||
"nutriaword",
|
"nutria@nutria.com",
|
||||||
local=False,
|
"nutriaword",
|
||||||
remote_id="https://example.com/users/nutria",
|
local=False,
|
||||||
inbox="https://example.com/users/nutria/inbox",
|
remote_id="https://example.com/users/nutria",
|
||||||
outbox="https://example.com/users/nutria/outbox",
|
inbox="https://example.com/users/nutria/inbox",
|
||||||
)
|
outbox="https://example.com/users/nutria/outbox",
|
||||||
|
)
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user", "recipients"))
|
MockSelf = namedtuple("Self", ("privacy", "user", "recipients"))
|
||||||
mock_self = MockSelf("direct", self.local_user, [another_remote_user])
|
mock_self = MockSelf("direct", self.local_user, [another_remote_user])
|
||||||
|
|
||||||
|
@ -187,17 +189,18 @@ class ActivitypubMixins(TestCase):
|
||||||
"""should combine users with the same shared_inbox"""
|
"""should combine users with the same shared_inbox"""
|
||||||
self.remote_user.shared_inbox = "http://example.com/inbox"
|
self.remote_user.shared_inbox = "http://example.com/inbox"
|
||||||
self.remote_user.save(broadcast=False)
|
self.remote_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
another_remote_user = models.User.objects.create_user(
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
"nutria",
|
another_remote_user = models.User.objects.create_user(
|
||||||
"nutria@nutria.com",
|
"nutria",
|
||||||
"nutriaword",
|
"nutria@nutria.com",
|
||||||
local=False,
|
"nutriaword",
|
||||||
remote_id="https://example.com/users/nutria",
|
local=False,
|
||||||
inbox="https://example.com/users/nutria/inbox",
|
remote_id="https://example.com/users/nutria",
|
||||||
shared_inbox="http://example.com/inbox",
|
inbox="https://example.com/users/nutria/inbox",
|
||||||
outbox="https://example.com/users/nutria/outbox",
|
shared_inbox="http://example.com/inbox",
|
||||||
)
|
outbox="https://example.com/users/nutria/outbox",
|
||||||
|
)
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
self.local_user.followers.add(self.remote_user)
|
self.local_user.followers.add(self.remote_user)
|
||||||
|
@ -209,17 +212,18 @@ class ActivitypubMixins(TestCase):
|
||||||
|
|
||||||
def test_get_recipients_software(self, _):
|
def test_get_recipients_software(self, _):
|
||||||
"""should differentiate between bookwyrm and other remote users"""
|
"""should differentiate between bookwyrm and other remote users"""
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
another_remote_user = models.User.objects.create_user(
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
"nutria",
|
another_remote_user = models.User.objects.create_user(
|
||||||
"nutria@nutria.com",
|
"nutria",
|
||||||
"nutriaword",
|
"nutria@nutria.com",
|
||||||
local=False,
|
"nutriaword",
|
||||||
remote_id="https://example.com/users/nutria",
|
local=False,
|
||||||
inbox="https://example.com/users/nutria/inbox",
|
remote_id="https://example.com/users/nutria",
|
||||||
outbox="https://example.com/users/nutria/outbox",
|
inbox="https://example.com/users/nutria/inbox",
|
||||||
bookwyrm_user=False,
|
outbox="https://example.com/users/nutria/outbox",
|
||||||
)
|
bookwyrm_user=False,
|
||||||
|
)
|
||||||
MockSelf = namedtuple("Self", ("privacy", "user"))
|
MockSelf = namedtuple("Self", ("privacy", "user"))
|
||||||
mock_self = MockSelf("public", self.local_user)
|
mock_self = MockSelf("public", self.local_user)
|
||||||
self.local_user.followers.add(self.remote_user)
|
self.local_user.followers.add(self.remote_user)
|
||||||
|
|
|
@ -16,16 +16,16 @@ class BaseModel(TestCase):
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
class BookWyrmTestModel(base_model.BookWyrmModel):
|
class BookWyrmTestModel(base_model.BookWyrmModel):
|
||||||
"""just making it not abstract"""
|
"""just making it not abstract"""
|
||||||
|
|
|
@ -11,29 +11,30 @@ class FederatedServer(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we'll need a user"""
|
"""we'll need a user"""
|
||||||
self.server = models.FederatedServer.objects.create(server_name="test.server")
|
self.server = models.FederatedServer.objects.create(server_name="test.server")
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
"rat",
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat@rat.com",
|
"rat",
|
||||||
"ratword",
|
"rat@rat.com",
|
||||||
federated_server=self.server,
|
"ratword",
|
||||||
local=False,
|
federated_server=self.server,
|
||||||
remote_id="https://example.com/users/rat",
|
local=False,
|
||||||
inbox="https://example.com/users/rat/inbox",
|
remote_id="https://example.com/users/rat",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
)
|
outbox="https://example.com/users/rat/outbox",
|
||||||
self.inactive_remote_user = models.User.objects.create_user(
|
)
|
||||||
"nutria",
|
self.inactive_remote_user = models.User.objects.create_user(
|
||||||
"nutria@nutria.com",
|
"nutria",
|
||||||
"nutriaword",
|
"nutria@nutria.com",
|
||||||
federated_server=self.server,
|
"nutriaword",
|
||||||
local=False,
|
federated_server=self.server,
|
||||||
remote_id="https://example.com/users/nutria",
|
local=False,
|
||||||
inbox="https://example.com/users/nutria/inbox",
|
remote_id="https://example.com/users/nutria",
|
||||||
outbox="https://example.com/users/nutria/outbox",
|
inbox="https://example.com/users/nutria/inbox",
|
||||||
is_active=False,
|
outbox="https://example.com/users/nutria/outbox",
|
||||||
deactivation_reason="self_deletion",
|
is_active=False,
|
||||||
)
|
deactivation_reason="self_deletion",
|
||||||
|
)
|
||||||
|
|
||||||
def test_block_unblock(self):
|
def test_block_unblock(self):
|
||||||
"""block a server and all users on it"""
|
"""block a server and all users on it"""
|
||||||
|
|
|
@ -10,17 +10,17 @@ class Relationship(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need some users for this"""
|
"""we need some users for this"""
|
||||||
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",
|
|
||||||
)
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
|
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(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,16 +25,16 @@ class Status(TestCase):
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.book = models.Edition.objects.create(title="Test Edition")
|
self.book = models.Edition.objects.create(title="Test Edition")
|
||||||
|
|
||||||
|
@ -356,11 +356,12 @@ class Status(TestCase):
|
||||||
status = models.Status.objects.create(
|
status = models.Status.objects.create(
|
||||||
content="test content", user=self.local_user
|
content="test content", user=self.local_user
|
||||||
)
|
)
|
||||||
fav = models.Favorite.objects.create(status=status, user=self.local_user)
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
|
fav = models.Favorite.objects.create(status=status, user=self.local_user)
|
||||||
|
|
||||||
# can't fav a status twice
|
# can't fav a status twice
|
||||||
with self.assertRaises(IntegrityError):
|
with self.assertRaises(IntegrityError):
|
||||||
models.Favorite.objects.create(status=status, user=self.local_user)
|
models.Favorite.objects.create(status=status, user=self.local_user)
|
||||||
|
|
||||||
activity = fav.to_activity()
|
activity = fav.to_activity()
|
||||||
self.assertEqual(activity["type"], "Like")
|
self.assertEqual(activity["type"], "Like")
|
||||||
|
|
|
@ -35,15 +35,16 @@ class User(TestCase):
|
||||||
self.assertIsNotNone(self.user.key_pair.public_key)
|
self.assertIsNotNone(self.user.key_pair.public_key)
|
||||||
|
|
||||||
def test_remote_user(self):
|
def test_remote_user(self):
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
user = models.User.objects.create_user(
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
"rat",
|
user = models.User.objects.create_user(
|
||||||
"rat@rat.rat",
|
"rat",
|
||||||
"ratword",
|
"rat@rat.rat",
|
||||||
local=False,
|
"ratword",
|
||||||
remote_id="https://example.com/dfjkg",
|
local=False,
|
||||||
bookwyrm_user=False,
|
remote_id="https://example.com/dfjkg",
|
||||||
)
|
bookwyrm_user=False,
|
||||||
|
)
|
||||||
self.assertEqual(user.username, "rat@example.com")
|
self.assertEqual(user.username, "rat@example.com")
|
||||||
|
|
||||||
def test_user_shelves(self):
|
def test_user_shelves(self):
|
||||||
|
|
|
@ -22,16 +22,16 @@ class Activitystreams(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="nutria",
|
localname="nutria",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.book = models.Edition.objects.create(title="test book")
|
self.book = models.Edition.objects.create(title="test book")
|
||||||
|
|
||||||
|
|
|
@ -119,9 +119,10 @@ class Signature(TestCase):
|
||||||
status=200,
|
status=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
response = self.send_test_request(sender=self.fake_remote)
|
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
||||||
self.assertEqual(response.status_code, 200)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_key_needs_refresh(self):
|
def test_key_needs_refresh(self):
|
||||||
|
@ -142,22 +143,23 @@ class Signature(TestCase):
|
||||||
data["publicKey"]["publicKeyPem"] = key_pair.public_key
|
data["publicKey"]["publicKeyPem"] = key_pair.public_key
|
||||||
responses.add(responses.GET, self.fake_remote.remote_id, json=data, status=200)
|
responses.add(responses.GET, self.fake_remote.remote_id, json=data, status=200)
|
||||||
|
|
||||||
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
# Key correct:
|
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
||||||
response = self.send_test_request(sender=self.fake_remote)
|
# Key correct:
|
||||||
self.assertEqual(response.status_code, 200)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
# Old key is cached, so still works:
|
# Old key is cached, so still works:
|
||||||
response = self.send_test_request(sender=self.fake_remote)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
# Try with new key:
|
# Try with new key:
|
||||||
response = self.send_test_request(sender=new_sender)
|
response = self.send_test_request(sender=new_sender)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
# Now the old key will fail:
|
# Now the old key will fail:
|
||||||
response = self.send_test_request(sender=self.fake_remote)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
self.assertEqual(response.status_code, 401)
|
self.assertEqual(response.status_code, 401)
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_nonexistent_signer(self):
|
def test_nonexistent_signer(self):
|
||||||
|
|
|
@ -29,14 +29,14 @@ class TemplateTags(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.rat",
|
"rat@rat.rat",
|
||||||
"ratword",
|
"ratword",
|
||||||
remote_id="http://example.com/rat",
|
remote_id="http://example.com/rat",
|
||||||
local=False,
|
local=False,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.book = models.Edition.objects.create(title="Test Book")
|
self.book = models.Edition.objects.create(title="Test Book")
|
||||||
|
|
||||||
|
@ -146,19 +146,20 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_book_description(self, _):
|
def test_get_book_description(self, _):
|
||||||
"""grab it from the edition or the parent"""
|
"""grab it from the edition or the parent"""
|
||||||
work = models.Work.objects.create(title="Test Work")
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.book.parent_work = work
|
work = models.Work.objects.create(title="Test Work")
|
||||||
self.book.save()
|
self.book.parent_work = work
|
||||||
|
self.book.save()
|
||||||
|
|
||||||
self.assertIsNone(bookwyrm_tags.get_book_description(self.book))
|
self.assertIsNone(bookwyrm_tags.get_book_description(self.book))
|
||||||
|
|
||||||
work.description = "hi"
|
work.description = "hi"
|
||||||
work.save()
|
work.save()
|
||||||
self.assertEqual(bookwyrm_tags.get_book_description(self.book), "hi")
|
self.assertEqual(bookwyrm_tags.get_book_description(self.book), "hi")
|
||||||
|
|
||||||
self.book.description = "hello"
|
self.book.description = "hello"
|
||||||
self.book.save()
|
self.book.save()
|
||||||
self.assertEqual(bookwyrm_tags.get_book_description(self.book), "hello")
|
self.assertEqual(bookwyrm_tags.get_book_description(self.book), "hello")
|
||||||
|
|
||||||
def test_get_uuid(self, _):
|
def test_get_uuid(self, _):
|
||||||
"""uuid functionality"""
|
"""uuid functionality"""
|
||||||
|
|
|
@ -29,16 +29,16 @@ class Inbox(TestCase):
|
||||||
)
|
)
|
||||||
local_user.remote_id = "https://example.com/user/mouse"
|
local_user.remote_id = "https://example.com/user/mouse"
|
||||||
local_user.save(broadcast=False)
|
local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
self.create_json = {
|
self.create_json = {
|
||||||
"id": "hi",
|
"id": "hi",
|
||||||
"type": "Create",
|
"type": "Create",
|
||||||
|
|
|
@ -23,16 +23,16 @@ class InboxAdd(TestCase):
|
||||||
)
|
)
|
||||||
local_user.remote_id = "https://example.com/user/mouse"
|
local_user.remote_id = "https://example.com/user/mouse"
|
||||||
local_user.save(broadcast=False)
|
local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
work = models.Work.objects.create(title="work title")
|
work = models.Work.objects.create(title="work title")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
|
|
|
@ -23,16 +23,16 @@ class InboxActivities(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
|
|
|
@ -22,16 +22,16 @@ class InboxBlock(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,16 @@ class InboxCreate(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
|
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",
|
||||||
|
)
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
self.status = models.Status.objects.create(
|
self.status = models.Status.objects.create(
|
||||||
|
@ -32,16 +42,6 @@ class InboxCreate(TestCase):
|
||||||
content="Test status",
|
content="Test status",
|
||||||
remote_id="https://example.com/status/1",
|
remote_id="https://example.com/status/1",
|
||||||
)
|
)
|
||||||
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.create_json = {
|
self.create_json = {
|
||||||
"id": "hi",
|
"id": "hi",
|
||||||
|
|
|
@ -23,16 +23,16 @@ class InboxActivities(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
self.status = models.Status.objects.create(
|
self.status = models.Status.objects.create(
|
||||||
user=self.remote_user,
|
user=self.remote_user,
|
||||||
|
@ -119,7 +119,8 @@ class InboxActivities(TestCase):
|
||||||
"object": self.remote_user.remote_id,
|
"object": self.remote_user.remote_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
views.inbox.activity_task(activity)
|
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
||||||
|
views.inbox.activity_task(activity)
|
||||||
self.assertFalse(models.User.objects.get(username="rat@example.com").is_active)
|
self.assertFalse(models.User.objects.get(username="rat@example.com").is_active)
|
||||||
|
|
||||||
def test_delete_user_unknown(self):
|
def test_delete_user_unknown(self):
|
||||||
|
|
|
@ -23,17 +23,17 @@ class InboxRelationships(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
|
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",
|
||||||
|
)
|
||||||
|
|
||||||
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",
|
|
||||||
)
|
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,16 @@ class InboxActivities(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
|
|
|
@ -22,16 +22,16 @@ class InboxRemove(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.work = models.Work.objects.create(title="work title")
|
self.work = models.Work.objects.create(title="work title")
|
||||||
|
|
|
@ -24,16 +24,16 @@ class InboxUpdate(TestCase):
|
||||||
)
|
)
|
||||||
self.local_user.remote_id = "https://example.com/user/mouse"
|
self.local_user.remote_id = "https://example.com/user/mouse"
|
||||||
self.local_user.save(broadcast=False)
|
self.local_user.save(broadcast=False)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.create_json = {
|
self.create_json = {
|
||||||
"id": "hi",
|
"id": "hi",
|
||||||
|
|
|
@ -22,16 +22,16 @@ class BlockViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
|
|
@ -23,16 +23,16 @@ class FederationViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
|
|
@ -25,16 +25,16 @@ class BookViews(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server"):
|
with patch("bookwyrm.models.user.set_remote_server"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@email.com",
|
"rat@email.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
self.group = Group.objects.create(name="editor")
|
self.group = Group.objects.create(name="editor")
|
||||||
self.group.permissions.add(
|
self.group.permissions.add(
|
||||||
Permission.objects.create(
|
Permission.objects.create(
|
||||||
|
|
|
@ -29,6 +29,17 @@ class ViewsHelpers(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
|
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",
|
||||||
|
discoverable=True,
|
||||||
|
inbox="https://example.com/users/rat/inbox",
|
||||||
|
outbox="https://example.com/users/rat/outbox",
|
||||||
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.work = models.Work.objects.create(title="Test Work")
|
self.work = models.Work.objects.create(title="Test Work")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
|
@ -36,17 +47,6 @@ class ViewsHelpers(TestCase):
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
)
|
)
|
||||||
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",
|
|
||||||
discoverable=True,
|
|
||||||
inbox="https://example.com/users/rat/inbox",
|
|
||||||
outbox="https://example.com/users/rat/outbox",
|
|
||||||
)
|
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")
|
||||||
self.userdata = json.loads(datafile.read_bytes())
|
self.userdata = json.loads(datafile.read_bytes())
|
||||||
del self.userdata["icon"]
|
del self.userdata["icon"]
|
||||||
|
|
|
@ -23,16 +23,16 @@ class InteractionViews(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server"):
|
with patch("bookwyrm.models.user.set_remote_server"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@email.com",
|
"rat@email.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
work = models.Work.objects.create(title="Test Work")
|
work = models.Work.objects.create(title="Test Work")
|
||||||
|
|
|
@ -24,6 +24,16 @@ class ReadingViews(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
|
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",
|
||||||
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
self.work = models.Work.objects.create(title="Test Work")
|
self.work = models.Work.objects.create(title="Test Work")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
|
@ -31,16 +41,6 @@ class ReadingViews(TestCase):
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
)
|
)
|
||||||
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",
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_start_reading(self, _):
|
def test_start_reading(self, _):
|
||||||
"""begin a book"""
|
"""begin a book"""
|
||||||
|
|
|
@ -24,16 +24,16 @@ class StatusViews(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server"):
|
with patch("bookwyrm.models.user.set_remote_server"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@email.com",
|
"rat@email.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
||||||
work = models.Work.objects.create(title="Test Work")
|
work = models.Work.objects.create(title="Test Work")
|
||||||
|
|
|
@ -27,16 +27,16 @@ class UserViews(TestCase):
|
||||||
models.User.objects.create_user(
|
models.User.objects.create_user(
|
||||||
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
|
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
models.User.objects.create_user(
|
models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
"rat@remote.com",
|
"rat@remote.com",
|
||||||
"ratword",
|
"ratword",
|
||||||
local=False,
|
local=False,
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
|
|
Loading…
Reference in a new issue