Merge branch 'main' into list-not-loading

This commit is contained in:
Mouse Reeve
2021-12-14 09:17:00 -08:00
27 changed files with 1394 additions and 649 deletions

View File

@ -1,5 +1,7 @@
""" testing models """
from dateutil.parser import parse
from imagekit.models import ImageSpecField
from django.test import TestCase
from django.utils import timezone
@ -26,11 +28,22 @@ class Book(TestCase):
def test_remote_id(self):
"""fanciness with remote/origin ids"""
remote_id = "https://%s/book/%d" % (settings.DOMAIN, self.work.id)
remote_id = f"https://{settings.DOMAIN}/book/{self.work.id}"
self.assertEqual(self.work.get_remote_id(), remote_id)
self.assertEqual(self.work.remote_id, remote_id)
def test_create_book(self):
def test_generated_links(self):
"""links produced from identifiers"""
book = models.Edition.objects.create(
title="ExEd",
parent_work=self.work,
openlibrary_key="OL123M",
inventaire_id="isbn:123",
)
self.assertEqual(book.openlibrary_link, "https://openlibrary.org/books/OL123M")
self.assertEqual(book.inventaire_link, "https://inventaire.io/entity/isbn:123")
def test_create_book_invalid(self):
"""you shouldn't be able to create Books (only editions and works)"""
self.assertRaises(ValueError, models.Book.objects.create, title="Invalid Book")

View File

@ -2,7 +2,7 @@
from unittest.mock import patch
from django.test import TestCase
from bookwyrm import models, settings
from bookwyrm import models
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
@ -67,7 +67,8 @@ class Group(TestCase):
models.GroupMember.objects.create(group=self.public_group, user=self.capybara)
def test_group_members_can_see_private_groups(self, _):
"""direct privacy group should not be excluded from group listings for group members viewing"""
"""direct privacy group should not be excluded from group listings for group
members viewing"""
rat_groups = models.Group.privacy_filter(self.rat).all()
badger_groups = models.Group.privacy_filter(self.badger).all()
@ -76,7 +77,8 @@ class Group(TestCase):
self.assertTrue(self.private_group in badger_groups)
def test_group_members_can_see_followers_only_lists(self, _):
"""follower-only group booklists should not be excluded from group booklist listing for group members who do not follower list owner"""
"""follower-only group booklists should not be excluded from group booklist
listing for group members who do not follower list owner"""
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
followers_list = models.List.objects.create(
@ -96,7 +98,8 @@ class Group(TestCase):
self.assertTrue(followers_list in capybara_lists)
def test_group_members_can_see_private_lists(self, _):
"""private group booklists should not be excluded from group booklist listing for group members"""
"""private group booklists should not be excluded from group booklist listing
for group members"""
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):