mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Refactors test mocks
This commit is contained in:
parent
7980d74b01
commit
6d8bced0f1
75 changed files with 1578 additions and 1826 deletions
2
.github/workflows/django-tests.yml
vendored
2
.github/workflows/django-tests.yml
vendored
|
@ -51,6 +51,6 @@ jobs:
|
||||||
EMAIL_HOST_USER: ""
|
EMAIL_HOST_USER: ""
|
||||||
EMAIL_HOST_PASSWORD: ""
|
EMAIL_HOST_PASSWORD: ""
|
||||||
EMAIL_USE_TLS: true
|
EMAIL_USE_TLS: true
|
||||||
ENABLE_PREVIEW_IMAGES: true
|
ENABLE_PREVIEW_IMAGES: false
|
||||||
run: |
|
run: |
|
||||||
pytest -n 3
|
pytest -n 3
|
||||||
|
|
|
@ -7,7 +7,6 @@ from bookwyrm import models
|
||||||
|
|
||||||
class Author(TestCase):
|
class Author(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
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",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
|
|
|
@ -25,7 +25,6 @@ class BaseActivity(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we're probably going to re-use this so why copy/paste"""
|
"""we're probably going to re-use this so why copy/paste"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
@ -98,7 +97,6 @@ class BaseActivity(TestCase):
|
||||||
status=200,
|
status=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
result = resolve_remote_id(
|
result = resolve_remote_id(
|
||||||
"https://example.com/user/mouse", model=models.User
|
"https://example.com/user/mouse", model=models.User
|
||||||
|
@ -141,7 +139,6 @@ class BaseActivity(TestCase):
|
||||||
self.user.avatar.file # pylint: disable=pointless-statement
|
self.user.avatar.file # pylint: disable=pointless-statement
|
||||||
|
|
||||||
# this would trigger a broadcast because it's a local user
|
# this would trigger a broadcast because it's a local user
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
activity.to_model(model=models.User, instance=self.user)
|
activity.to_model(model=models.User, instance=self.user)
|
||||||
self.assertIsNotNone(self.user.avatar.file)
|
self.assertIsNotNone(self.user.avatar.file)
|
||||||
|
@ -155,7 +152,6 @@ class BaseActivity(TestCase):
|
||||||
content="test status",
|
content="test status",
|
||||||
user=self.user,
|
user=self.user,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
title="Test Edition", remote_id="http://book.com/book"
|
title="Test Edition", remote_id="http://book.com/book"
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,7 +20,6 @@ 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.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
user = activity.to_model(model=models.User)
|
user = activity.to_model(model=models.User)
|
||||||
self.assertEqual(user.username, "mouse@example.com")
|
self.assertEqual(user.username, "mouse@example.com")
|
||||||
|
|
|
@ -12,7 +12,6 @@ class Quotation(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""model objects we'll need"""
|
"""model objects we'll need"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"mouse",
|
"mouse",
|
||||||
|
@ -23,7 +22,6 @@ class Quotation(TestCase):
|
||||||
outbox="https://example.com/user/mouse/outbox",
|
outbox="https://example.com/user/mouse/outbox",
|
||||||
remote_id="https://example.com/user/mouse",
|
remote_id="https://example.com/user/mouse",
|
||||||
)
|
)
|
||||||
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",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
|
|
|
@ -74,7 +74,6 @@ class AbstractConnector(TestCase):
|
||||||
Mapping("openlibraryKey"),
|
Mapping("openlibraryKey"),
|
||||||
]
|
]
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Test Book",
|
title="Test Book",
|
||||||
remote_id="https://example.com/book/1234",
|
remote_id="https://example.com/book/1234",
|
||||||
|
@ -111,7 +110,6 @@ class AbstractConnector(TestCase):
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET, "https://example.com/book/abcd", json=self.edition_data
|
responses.GET, "https://example.com/book/abcd", json=self.edition_data
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.connectors.abstract_connector.load_more_data.delay"):
|
with patch("bookwyrm.connectors.abstract_connector.load_more_data.delay"):
|
||||||
result = self.connector.get_or_create_book(
|
result = self.connector.get_or_create_book(
|
||||||
"https://example.com/book/abcd"
|
"https://example.com/book/abcd"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
""" testing book data connectors """
|
""" testing book data connectors """
|
||||||
from unittest.mock import patch
|
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -26,7 +25,6 @@ class BookWyrmConnector(TestCase):
|
||||||
|
|
||||||
def test_get_or_create_book_existing(self):
|
def test_get_or_create_book_existing(self):
|
||||||
"""load book activity"""
|
"""load book activity"""
|
||||||
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")
|
||||||
book = models.Edition.objects.create(title="Test Edition", parent_work=work)
|
book = models.Edition.objects.create(title="Test Edition", parent_work=work)
|
||||||
result = self.connector.get_or_create_book(book.remote_id)
|
result = self.connector.get_or_create_book(book.remote_id)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
""" interface between the app and various connectors """
|
""" interface between the app and various connectors """
|
||||||
from unittest.mock import patch
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
import responses
|
import responses
|
||||||
|
|
||||||
|
@ -14,7 +13,6 @@ class ConnectorManager(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we'll need some books and a connector info entry"""
|
"""we'll need some books and a connector info entry"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.work = models.Work.objects.create(title="Example Work")
|
self.work = models.Work.objects.create(title="Example Work")
|
||||||
|
|
||||||
self.edition = models.Edition.objects.create(
|
self.edition = models.Edition.objects.create(
|
||||||
|
|
|
@ -178,7 +178,6 @@ class Openlibrary(TestCase):
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_expand_book_data(self):
|
def test_expand_book_data(self):
|
||||||
"""given a book, get more editions"""
|
"""given a book, get more editions"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
work = models.Work.objects.create(
|
work = models.Work.objects.create(
|
||||||
title="Test Work", openlibrary_key="OL1234W"
|
title="Test Work", openlibrary_key="OL1234W"
|
||||||
)
|
)
|
||||||
|
@ -191,7 +190,6 @@ class Openlibrary(TestCase):
|
||||||
"https://openlibrary.org/works/OL1234W/editions",
|
"https://openlibrary.org/works/OL1234W/editions",
|
||||||
json={"entries": []},
|
json={"entries": []},
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.connectors.abstract_connector.AbstractConnector."
|
"bookwyrm.connectors.abstract_connector.AbstractConnector."
|
||||||
"create_edition_from_data"
|
"create_edition_from_data"
|
||||||
|
@ -230,7 +228,6 @@ class Openlibrary(TestCase):
|
||||||
json={"hi": "there"},
|
json={"hi": "there"},
|
||||||
status=200,
|
status=200,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
|
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
|
||||||
) as mock:
|
) as mock:
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
""" testing book data connectors """
|
""" testing book data connectors """
|
||||||
from unittest.mock import patch
|
|
||||||
import datetime
|
import datetime
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -30,7 +29,6 @@ class SelfConnector(TestCase):
|
||||||
def test_format_search_result(self):
|
def test_format_search_result(self):
|
||||||
"""create a SearchResult"""
|
"""create a SearchResult"""
|
||||||
author = models.Author.objects.create(name="Anonymous")
|
author = models.Author.objects.create(name="Anonymous")
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
edition = models.Edition.objects.create(
|
edition = models.Edition.objects.create(
|
||||||
title="Edition of Example Work",
|
title="Edition of Example Work",
|
||||||
published_date=datetime.datetime(1980, 5, 10, tzinfo=timezone.utc),
|
published_date=datetime.datetime(1980, 5, 10, tzinfo=timezone.utc),
|
||||||
|
@ -43,8 +41,7 @@ class SelfConnector(TestCase):
|
||||||
self.assertEqual(result.year, 1980)
|
self.assertEqual(result.year, 1980)
|
||||||
self.assertEqual(result.connector, self.connector)
|
self.assertEqual(result.connector, self.connector)
|
||||||
|
|
||||||
@patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay")
|
def test_search_rank(self):
|
||||||
def test_search_rank(self, _):
|
|
||||||
"""prioritize certain results"""
|
"""prioritize certain results"""
|
||||||
author = models.Author.objects.create(name="Anonymous")
|
author = models.Author.objects.create(name="Anonymous")
|
||||||
edition = models.Edition.objects.create(
|
edition = models.Edition.objects.create(
|
||||||
|
@ -81,8 +78,7 @@ class SelfConnector(TestCase):
|
||||||
self.assertEqual(results[2].title, "Edition of Example Work")
|
self.assertEqual(results[2].title, "Edition of Example Work")
|
||||||
self.assertEqual(results[3].title, "Another Edition")
|
self.assertEqual(results[3].title, "Another Edition")
|
||||||
|
|
||||||
@patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay")
|
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"""
|
||||||
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(
|
||||||
|
|
|
@ -27,7 +27,6 @@ class GoodreadsImport(TestCase):
|
||||||
self.importer = GoodreadsImporter()
|
self.importer = GoodreadsImporter()
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/goodreads.csv")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/goodreads.csv")
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "password", local=True
|
"mouse", "mouse@mouse.mouse", "password", local=True
|
||||||
)
|
)
|
||||||
|
@ -43,7 +42,6 @@ class GoodreadsImport(TestCase):
|
||||||
search_url="https://%s/search?q=" % DOMAIN,
|
search_url="https://%s/search?q=" % DOMAIN,
|
||||||
priority=1,
|
priority=1,
|
||||||
)
|
)
|
||||||
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")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -100,7 +98,6 @@ class GoodreadsImport(TestCase):
|
||||||
def test_import_data(self):
|
def test_import_data(self):
|
||||||
"""resolve entry"""
|
"""resolve entry"""
|
||||||
import_job = self.importer.create_job(self.user, self.csv, False, "unlisted")
|
import_job = self.importer.create_job(self.user, self.csv, False, "unlisted")
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Edition.objects.create(title="Test Book")
|
book = models.Edition.objects.create(title="Test Book")
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -128,7 +125,6 @@ class GoodreadsImport(TestCase):
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, False, "public"
|
self.importer.service, self.user, import_item, False, "public"
|
||||||
|
@ -196,7 +192,6 @@ class GoodreadsImport(TestCase):
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, False, "public"
|
self.importer.service, self.user, import_item, False, "public"
|
||||||
|
@ -228,7 +223,6 @@ class GoodreadsImport(TestCase):
|
||||||
job_id=import_job.id, index=0, data=entry, book=self.book
|
job_id=import_job.id, index=0, data=entry, book=self.book
|
||||||
)
|
)
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, True, "unlisted"
|
self.importer.service, self.user, import_item, True, "unlisted"
|
||||||
|
@ -253,7 +247,6 @@ class GoodreadsImport(TestCase):
|
||||||
job_id=import_job.id, index=0, data=entry, book=self.book
|
job_id=import_job.id, index=0, data=entry, book=self.book
|
||||||
)
|
)
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, True, "unlisted"
|
self.importer.service, self.user, import_item, True, "unlisted"
|
||||||
|
@ -275,7 +268,6 @@ class GoodreadsImport(TestCase):
|
||||||
job_id=import_job.id, index=0, data=entry, book=self.book
|
job_id=import_job.id, index=0, data=entry, book=self.book
|
||||||
)
|
)
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, False, "unlisted"
|
self.importer.service, self.user, import_item, False, "unlisted"
|
||||||
|
|
|
@ -15,6 +15,7 @@ from bookwyrm.settings import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
def make_date(*args):
|
def make_date(*args):
|
||||||
|
"""helper function to easily generate a date obj"""
|
||||||
return datetime.datetime(*args, tzinfo=pytz.UTC)
|
return datetime.datetime(*args, tzinfo=pytz.UTC)
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +29,6 @@ class LibrarythingImport(TestCase):
|
||||||
|
|
||||||
# Librarything generates latin encoded exports...
|
# Librarything generates latin encoded exports...
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"mmai", "mmai@mmai.mmai", "password", local=True
|
"mmai", "mmai@mmai.mmai", "password", local=True
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,6 @@ class LibrarythingImport(TestCase):
|
||||||
search_url="https://%s/search?q=" % DOMAIN,
|
search_url="https://%s/search?q=" % DOMAIN,
|
||||||
priority=1,
|
priority=1,
|
||||||
)
|
)
|
||||||
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")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -90,7 +89,6 @@ class LibrarythingImport(TestCase):
|
||||||
def test_import_data(self):
|
def test_import_data(self):
|
||||||
"""resolve entry"""
|
"""resolve entry"""
|
||||||
import_job = self.importer.create_job(self.user, self.csv, False, "unlisted")
|
import_job = self.importer.create_job(self.user, self.csv, False, "unlisted")
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Edition.objects.create(title="Test Book")
|
book = models.Edition.objects.create(title="Test Book")
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -120,7 +118,6 @@ class LibrarythingImport(TestCase):
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, False, "public"
|
self.importer.service, self.user, import_item, False, "public"
|
||||||
|
@ -152,7 +149,6 @@ class LibrarythingImport(TestCase):
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, False, "public"
|
self.importer.service, self.user, import_item, False, "public"
|
||||||
|
@ -182,7 +178,6 @@ class LibrarythingImport(TestCase):
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, False, "public"
|
self.importer.service, self.user, import_item, False, "public"
|
||||||
|
@ -211,7 +206,6 @@ class LibrarythingImport(TestCase):
|
||||||
job_id=import_job.id, index=0, data=entry, book=self.book
|
job_id=import_job.id, index=0, data=entry, book=self.book
|
||||||
)
|
)
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, True, "unlisted"
|
self.importer.service, self.user, import_item, True, "unlisted"
|
||||||
|
@ -233,7 +227,6 @@ class LibrarythingImport(TestCase):
|
||||||
job_id=import_job.id, index=0, data=entry, book=self.book
|
job_id=import_job.id, index=0, data=entry, book=self.book
|
||||||
)
|
)
|
||||||
|
|
||||||
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"):
|
||||||
handle_imported_book(
|
handle_imported_book(
|
||||||
self.importer.service, self.user, import_item, False, "unlisted"
|
self.importer.service, self.user, import_item, False, "unlisted"
|
||||||
|
|
|
@ -12,7 +12,6 @@ class Activitystreams(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need some stuff"""
|
"""we need some stuff"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
@ -33,7 +32,6 @@ class Activitystreams(TestCase):
|
||||||
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"):
|
|
||||||
self.book = models.Edition.objects.create(title="test book")
|
self.book = models.Edition.objects.create(title="test book")
|
||||||
|
|
||||||
def test_populate_streams(self, _):
|
def test_populate_streams(self, _):
|
||||||
|
|
|
@ -21,13 +21,12 @@ from bookwyrm.settings import PAGE_LENGTH
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
||||||
@patch("bookwyrm.preview_images.generate_user_preview_image_task.delay")
|
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||||
class ActivitypubMixins(TestCase):
|
class ActivitypubMixins(TestCase):
|
||||||
"""functionality shared across models"""
|
"""functionality shared across models"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""shared data"""
|
"""shared data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
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"
|
||||||
)
|
)
|
||||||
|
@ -78,7 +77,6 @@ class ActivitypubMixins(TestCase):
|
||||||
"""attempt to match a remote id to an object in the db"""
|
"""attempt to match a remote id to an object in the db"""
|
||||||
# uses a different remote id scheme
|
# uses a different remote id scheme
|
||||||
# this isn't really part of this test directly but it's helpful to state
|
# this isn't really part of this test directly but it's helpful to state
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
title="Test Edition", remote_id="http://book.com/book"
|
title="Test Edition", remote_id="http://book.com/book"
|
||||||
)
|
)
|
||||||
|
@ -87,7 +85,6 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertNotEqual(book.remote_id, "http://book.com/book")
|
self.assertNotEqual(book.remote_id, "http://book.com/book")
|
||||||
|
|
||||||
# uses subclasses
|
# uses subclasses
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
|
||||||
models.Comment.objects.create(
|
models.Comment.objects.create(
|
||||||
user=self.local_user,
|
user=self.local_user,
|
||||||
content="test status",
|
content="test status",
|
||||||
|
@ -110,7 +107,6 @@ class ActivitypubMixins(TestCase):
|
||||||
|
|
||||||
def test_find_existing(self, *_):
|
def test_find_existing(self, *_):
|
||||||
"""match a blob of data to a model"""
|
"""match a blob of data to a model"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
title="Test edition",
|
title="Test edition",
|
||||||
openlibrary_key="OL1234",
|
openlibrary_key="OL1234",
|
||||||
|
@ -369,7 +365,6 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(activity["type"], "Undo")
|
self.assertEqual(activity["type"], "Undo")
|
||||||
self.assertIsInstance(activity["object"], dict)
|
self.assertIsInstance(activity["object"], dict)
|
||||||
|
|
||||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
|
||||||
def test_to_ordered_collection_page(self, *_):
|
def test_to_ordered_collection_page(self, *_):
|
||||||
"""make sure the paged results of an ordered collection work"""
|
"""make sure the paged results of an ordered collection work"""
|
||||||
self.assertEqual(PAGE_LENGTH, 15)
|
self.assertEqual(PAGE_LENGTH, 15)
|
||||||
|
@ -395,7 +390,6 @@ class ActivitypubMixins(TestCase):
|
||||||
self.assertEqual(page_2.orderedItems[0]["content"], "test status 14")
|
self.assertEqual(page_2.orderedItems[0]["content"], "test status 14")
|
||||||
self.assertEqual(page_2.orderedItems[-1]["content"], "test status 0")
|
self.assertEqual(page_2.orderedItems[-1]["content"], "test status 0")
|
||||||
|
|
||||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
|
||||||
def test_to_ordered_collection(self, *_):
|
def test_to_ordered_collection(self, *_):
|
||||||
"""convert a queryset into an ordered collection object"""
|
"""convert a queryset into an ordered collection object"""
|
||||||
self.assertEqual(PAGE_LENGTH, 15)
|
self.assertEqual(PAGE_LENGTH, 15)
|
||||||
|
|
|
@ -7,12 +7,12 @@ from bookwyrm.models import base_model
|
||||||
from bookwyrm.settings import DOMAIN
|
from bookwyrm.settings import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
class BaseModel(TestCase):
|
class BaseModel(TestCase):
|
||||||
"""functionality shared across models"""
|
"""functionality shared across models"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""shared data"""
|
"""shared data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
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"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
""" testing models """
|
""" testing models """
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -14,7 +12,6 @@ class Book(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we'll need some books"""
|
"""we'll need some books"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.work = models.Work.objects.create(
|
self.work = models.Work.objects.create(
|
||||||
title="Example Work", remote_id="https://example.com/book/1"
|
title="Example Work", remote_id="https://example.com/book/1"
|
||||||
)
|
)
|
||||||
|
@ -59,7 +56,6 @@ class Book(TestCase):
|
||||||
|
|
||||||
def test_get_edition_info(self):
|
def test_get_edition_info(self):
|
||||||
"""text slug about an edition"""
|
"""text slug about an edition"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Edition.objects.create(title="Test Edition")
|
book = models.Edition.objects.create(title="Test Edition")
|
||||||
self.assertEqual(book.edition_info, "")
|
self.assertEqual(book.edition_info, "")
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ 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.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
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",
|
||||||
|
|
|
@ -188,7 +188,6 @@ class ActivitypubFields(TestCase):
|
||||||
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
||||||
def test_privacy_field_set_activity_from_field(self, *_):
|
def test_privacy_field_set_activity_from_field(self, *_):
|
||||||
"""translate between to/cc fields and privacy"""
|
"""translate between to/cc fields and privacy"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
||||||
)
|
)
|
||||||
|
@ -249,7 +248,6 @@ class ActivitypubFields(TestCase):
|
||||||
del userdata["icon"]
|
del userdata["icon"]
|
||||||
|
|
||||||
# it shouldn't match with this unrelated user:
|
# it shouldn't match with this unrelated user:
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
unrelated_user = User.objects.create_user(
|
unrelated_user = User.objects.create_user(
|
||||||
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
||||||
)
|
)
|
||||||
|
@ -277,7 +275,6 @@ class ActivitypubFields(TestCase):
|
||||||
del userdata["icon"]
|
del userdata["icon"]
|
||||||
|
|
||||||
# it shouldn't match with this unrelated user:
|
# it shouldn't match with this unrelated user:
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
unrelated_user = User.objects.create_user(
|
unrelated_user = User.objects.create_user(
|
||||||
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
|
||||||
)
|
)
|
||||||
|
@ -294,7 +291,6 @@ class ActivitypubFields(TestCase):
|
||||||
instance = fields.ForeignKey(User, on_delete=models.CASCADE)
|
instance = fields.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")
|
||||||
userdata = json.loads(datafile.read_bytes())
|
userdata = json.loads(datafile.read_bytes())
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
@ -312,7 +308,6 @@ class ActivitypubFields(TestCase):
|
||||||
def test_foreign_key_from_activity_str_existing(self):
|
def test_foreign_key_from_activity_str_existing(self):
|
||||||
"""test receiving a remote id of an existing object in the db"""
|
"""test receiving a remote id of an existing object in the db"""
|
||||||
instance = fields.ForeignKey(User, on_delete=models.CASCADE)
|
instance = fields.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
@ -360,7 +355,6 @@ class ActivitypubFields(TestCase):
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET, "https://example.com/user/mouse", json=userdata, status=200
|
responses.GET, "https://example.com/user/mouse", json=userdata, status=200
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
value = instance.field_from_activity(
|
value = instance.field_from_activity(
|
||||||
["https://example.com/user/mouse", "bleh"]
|
["https://example.com/user/mouse", "bleh"]
|
||||||
|
@ -396,7 +390,6 @@ class ActivitypubFields(TestCase):
|
||||||
@patch("bookwyrm.models.activitypub_mixin.ObjectMixin.broadcast")
|
@patch("bookwyrm.models.activitypub_mixin.ObjectMixin.broadcast")
|
||||||
def test_image_field(self, _):
|
def test_image_field(self, _):
|
||||||
"""storing images"""
|
"""storing images"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
|
|
@ -59,7 +59,6 @@ class ImportJob(TestCase):
|
||||||
unknown_read_data["Exclusive Shelf"] = "read"
|
unknown_read_data["Exclusive Shelf"] = "read"
|
||||||
unknown_read_data["Date Read"] = ""
|
unknown_read_data["Date Read"] = ""
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = models.User.objects.create_user(
|
user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
@ -174,9 +173,6 @@ class ImportJob(TestCase):
|
||||||
search.return_value = result
|
search.return_value = result
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
|
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
|
||||||
):
|
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
):
|
||||||
book = self.item_1.get_book_from_isbn()
|
book = self.item_1.get_book_from_isbn()
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,9 @@ class List(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""look, a list"""
|
"""look, a list"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
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.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
work = models.Work.objects.create(title="hello")
|
work = models.Work.objects.create(title="hello")
|
||||||
self.book = models.Edition.objects.create(title="hi", parent_work=work)
|
self.book = models.Edition.objects.create(title="hi", parent_work=work)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
""" testing models """
|
""" testing models """
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
|
|
||||||
|
@ -11,12 +10,10 @@ class ReadThrough(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""look, a shelf"""
|
"""look, a shelf"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.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.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.work = models.Work.objects.create(title="Example Work")
|
self.work = models.Work.objects.create(title="Example Work")
|
||||||
self.edition = models.Edition.objects.create(
|
self.edition = models.Edition.objects.create(
|
||||||
title="Example Edition", parent_work=self.work
|
title="Example Edition", parent_work=self.work
|
||||||
|
|
|
@ -10,7 +10,6 @@ class Relationship(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need some users for this"""
|
"""we need some users for this"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
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",
|
||||||
|
|
|
@ -12,11 +12,9 @@ class Shelf(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""look, a shelf"""
|
"""look, a shelf"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
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.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
work = models.Work.objects.create(title="Test Work")
|
work = models.Work.objects.create(title="Test Work")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="test book", parent_work=work
|
title="test book", parent_work=work
|
||||||
|
|
|
@ -22,7 +22,6 @@ class Status(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""useful things for creating a status"""
|
"""useful things for creating a status"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
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"
|
||||||
)
|
)
|
||||||
|
@ -36,7 +35,6 @@ class Status(TestCase):
|
||||||
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"):
|
|
||||||
self.book = models.Edition.objects.create(title="Test Edition")
|
self.book = models.Edition.objects.create(title="Test Edition")
|
||||||
|
|
||||||
image_file = pathlib.Path(__file__).parent.joinpath(
|
image_file = pathlib.Path(__file__).parent.joinpath(
|
||||||
|
@ -61,7 +59,6 @@ class Status(TestCase):
|
||||||
child = models.Status.objects.create(
|
child = models.Status.objects.create(
|
||||||
content="hello", reply_parent=parent, user=self.local_user
|
content="hello", reply_parent=parent, user=self.local_user
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
models.Review.objects.create(
|
models.Review.objects.create(
|
||||||
content="hey", reply_parent=parent, user=self.local_user, book=self.book
|
content="hey", reply_parent=parent, user=self.local_user, book=self.book
|
||||||
)
|
)
|
||||||
|
@ -96,7 +93,6 @@ class Status(TestCase):
|
||||||
child = models.Status.objects.create(
|
child = models.Status.objects.create(
|
||||||
content="hello", reply_parent=parent, user=self.local_user
|
content="hello", reply_parent=parent, user=self.local_user
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
models.Review.objects.create(
|
models.Review.objects.create(
|
||||||
content="hey", reply_parent=parent, user=self.local_user, book=self.book
|
content="hey", reply_parent=parent, user=self.local_user, book=self.book
|
||||||
)
|
)
|
||||||
|
@ -256,7 +252,6 @@ class Status(TestCase):
|
||||||
|
|
||||||
def test_review_to_activity(self, *_):
|
def test_review_to_activity(self, *_):
|
||||||
"""subclass of the base model version with a "pure" serializer"""
|
"""subclass of the base model version with a "pure" serializer"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
name="Review name",
|
name="Review name",
|
||||||
content="test content",
|
content="test content",
|
||||||
|
@ -274,7 +269,6 @@ class Status(TestCase):
|
||||||
|
|
||||||
def test_review_to_pure_activity(self, *_):
|
def test_review_to_pure_activity(self, *_):
|
||||||
"""subclass of the base model version with a "pure" serializer"""
|
"""subclass of the base model version with a "pure" serializer"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
name="Review's name",
|
name="Review's name",
|
||||||
content="test content",
|
content="test content",
|
||||||
|
@ -299,7 +293,6 @@ class Status(TestCase):
|
||||||
|
|
||||||
def test_review_to_pure_activity_no_rating(self, *_):
|
def test_review_to_pure_activity_no_rating(self, *_):
|
||||||
"""subclass of the base model version with a "pure" serializer"""
|
"""subclass of the base model version with a "pure" serializer"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
name="Review name",
|
name="Review name",
|
||||||
content="test content",
|
content="test content",
|
||||||
|
@ -322,7 +315,6 @@ class Status(TestCase):
|
||||||
|
|
||||||
def test_reviewrating_to_pure_activity(self, *_):
|
def test_reviewrating_to_pure_activity(self, *_):
|
||||||
"""subclass of the base model version with a "pure" serializer"""
|
"""subclass of the base model version with a "pure" serializer"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
status = models.ReviewRating.objects.create(
|
status = models.ReviewRating.objects.create(
|
||||||
rating=3.0,
|
rating=3.0,
|
||||||
user=self.local_user,
|
user=self.local_user,
|
||||||
|
@ -357,7 +349,6 @@ 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
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
fav = models.Favorite.objects.create(status=status, user=self.local_user)
|
fav = models.Favorite.objects.create(status=status, user=self.local_user)
|
||||||
|
|
||||||
# can't fav a status twice
|
# can't fav a status twice
|
||||||
|
|
|
@ -11,7 +11,6 @@ from bookwyrm.settings import DOMAIN
|
||||||
# pylint: disable=missing-function-docstring
|
# pylint: disable=missing-function-docstring
|
||||||
class User(TestCase):
|
class User(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"mouse@%s" % DOMAIN,
|
"mouse@%s" % DOMAIN,
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -35,7 +34,6 @@ 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.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
user = models.User.objects.create_user(
|
user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
|
|
|
@ -11,7 +11,6 @@ class Activitystreams(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
|
@ -32,7 +31,6 @@ class Activitystreams(TestCase):
|
||||||
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"):
|
|
||||||
self.book = models.Edition.objects.create(title="test book")
|
self.book = models.Edition.objects.create(title="test book")
|
||||||
|
|
||||||
class TestStream(activitystreams.ActivityStream):
|
class TestStream(activitystreams.ActivityStream):
|
||||||
|
|
|
@ -3,7 +3,6 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
import responses
|
|
||||||
|
|
||||||
from bookwyrm import emailing, models
|
from bookwyrm import emailing, models
|
||||||
|
|
||||||
|
@ -15,7 +14,6 @@ class Emailing(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -23,7 +21,6 @@ class Emailing(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_invite_email(self, email_mock):
|
def test_invite_email(self, email_mock):
|
||||||
|
|
|
@ -6,17 +6,16 @@ from bookwyrm import models
|
||||||
|
|
||||||
|
|
||||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||||
@patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay")
|
|
||||||
class PostgresTriggers(TestCase):
|
class PostgresTriggers(TestCase):
|
||||||
"""special migrations, fancy stuff ya know"""
|
"""special migrations, fancy stuff ya know"""
|
||||||
|
|
||||||
def test_search_vector_on_create(self, *_):
|
def test_search_vector_on_create(self, _):
|
||||||
"""make sure that search_vector is being set correctly on create"""
|
"""make sure that search_vector is being set correctly on create"""
|
||||||
book = models.Edition.objects.create(title="The Long Goodbye")
|
book = models.Edition.objects.create(title="The Long Goodbye")
|
||||||
book.refresh_from_db()
|
book.refresh_from_db()
|
||||||
self.assertEqual(book.search_vector, "'goodby':3A 'long':2A")
|
self.assertEqual(book.search_vector, "'goodby':3A 'long':2A")
|
||||||
|
|
||||||
def test_search_vector_on_update(self, *_):
|
def test_search_vector_on_update(self, _):
|
||||||
"""make sure that search_vector is being set correctly on edit"""
|
"""make sure that search_vector is being set correctly on edit"""
|
||||||
book = models.Edition.objects.create(title="The Long Goodbye")
|
book = models.Edition.objects.create(title="The Long Goodbye")
|
||||||
book.title = "The Even Longer Goodbye"
|
book.title = "The Even Longer Goodbye"
|
||||||
|
@ -24,7 +23,7 @@ class PostgresTriggers(TestCase):
|
||||||
book.refresh_from_db()
|
book.refresh_from_db()
|
||||||
self.assertEqual(book.search_vector, "'even':2A 'goodby':4A 'longer':3A")
|
self.assertEqual(book.search_vector, "'even':2A 'goodby':4A 'longer':3A")
|
||||||
|
|
||||||
def test_search_vector_fields(self, *_):
|
def test_search_vector_fields(self, _):
|
||||||
"""use multiple fields to create search vector"""
|
"""use multiple fields to create search vector"""
|
||||||
author = models.Author.objects.create(name="The Rays")
|
author = models.Author.objects.create(name="The Rays")
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
|
@ -40,7 +39,7 @@ class PostgresTriggers(TestCase):
|
||||||
"'cool':5B 'goodby':3A 'long':2A 'name':9 'rays':7C 'seri':8 'the':6C 'wow':4B",
|
"'cool':5B 'goodby':3A 'long':2A 'name':9 'rays':7C 'seri':8 'the':6C 'wow':4B",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_seach_vector_on_author_update(self, *_):
|
def test_seach_vector_on_author_update(self, _):
|
||||||
"""update search when an author name changes"""
|
"""update search when an author name changes"""
|
||||||
author = models.Author.objects.create(name="The Rays")
|
author = models.Author.objects.create(name="The Rays")
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
|
@ -53,7 +52,7 @@ class PostgresTriggers(TestCase):
|
||||||
|
|
||||||
self.assertEqual(book.search_vector, "'goodby':3A 'jeremy':4C 'long':2A")
|
self.assertEqual(book.search_vector, "'goodby':3A 'jeremy':4C 'long':2A")
|
||||||
|
|
||||||
def test_seach_vector_on_author_delete(self, *_):
|
def test_seach_vector_on_author_delete(self, _):
|
||||||
"""update search when an author name changes"""
|
"""update search when an author name changes"""
|
||||||
author = models.Author.objects.create(name="Jeremy")
|
author = models.Author.objects.create(name="Jeremy")
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
|
@ -68,7 +67,7 @@ class PostgresTriggers(TestCase):
|
||||||
book.refresh_from_db()
|
book.refresh_from_db()
|
||||||
self.assertEqual(book.search_vector, "'goodby':3A 'long':2A")
|
self.assertEqual(book.search_vector, "'goodby':3A 'long':2A")
|
||||||
|
|
||||||
def test_search_vector_stop_word_fallback(self, *_):
|
def test_search_vector_stop_word_fallback(self, _):
|
||||||
"""use a fallback when removing stop words leads to an empty vector"""
|
"""use a fallback when removing stop words leads to an empty vector"""
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
title="there there",
|
title="there there",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
""" test generating preview images """
|
""" test generating preview images """
|
||||||
import pathlib
|
import pathlib
|
||||||
from unittest.mock import patch
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -27,7 +26,6 @@ class PreviewImages(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
avatar_file = pathlib.Path(__file__).parent.joinpath(
|
avatar_file = pathlib.Path(__file__).parent.joinpath(
|
||||||
"../static/images/no_cover.jpg"
|
"../static/images/no_cover.jpg"
|
||||||
)
|
)
|
||||||
|
@ -43,16 +41,18 @@ class PreviewImages(TestCase):
|
||||||
content_type="image/jpeg",
|
content_type="image/jpeg",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
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.edition = models.Edition.objects.create(
|
self.edition = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
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.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
self.site = models.SiteSettings.objects.create()
|
self.site = models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
settings.ENABLE_PREVIEW_IMAGES = True
|
||||||
|
|
||||||
def test_generate_preview_image(self, *args, **kwargs):
|
def test_generate_preview_image(self, *args, **kwargs):
|
||||||
image_file = pathlib.Path(__file__).parent.joinpath(
|
image_file = pathlib.Path(__file__).parent.joinpath(
|
||||||
"../static/images/no_cover.jpg"
|
"../static/images/no_cover.jpg"
|
||||||
|
|
|
@ -37,7 +37,6 @@ class Signature(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""create users and test data"""
|
"""create users and test data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.mouse = models.User.objects.create_user(
|
self.mouse = models.User.objects.create_user(
|
||||||
"mouse@%s" % DOMAIN,
|
"mouse@%s" % DOMAIN,
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
|
@ -58,7 +57,6 @@ class Signature(TestCase):
|
||||||
"http://localhost/user/remote", KeyPair(private_key, public_key)
|
"http://localhost/user/remote", KeyPair(private_key, public_key)
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def send(self, signature, now, data, digest):
|
def send(self, signature, now, data, digest):
|
||||||
|
@ -119,7 +117,6 @@ class Signature(TestCase):
|
||||||
status=200,
|
status=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
||||||
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)
|
||||||
|
@ -143,7 +140,6 @@ 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.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
with patch("bookwyrm.models.user.get_remote_reviews.delay"):
|
||||||
# Key correct:
|
# Key correct:
|
||||||
response = self.send_test_request(sender=self.fake_remote)
|
response = self.send_test_request(sender=self.fake_remote)
|
||||||
|
|
|
@ -22,7 +22,6 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -38,12 +37,10 @@ class TemplateTags(TestCase):
|
||||||
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"):
|
|
||||||
self.book = models.Edition.objects.create(title="Test Book")
|
self.book = models.Edition.objects.create(title="Test Book")
|
||||||
|
|
||||||
def test_get_user_rating(self, *_):
|
def test_get_user_rating(self, *_):
|
||||||
"""get a user's most recent rating of a book"""
|
"""get a user's most recent rating of a book"""
|
||||||
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"):
|
||||||
models.Review.objects.create(user=self.user, book=self.book, rating=3)
|
models.Review.objects.create(user=self.user, book=self.book, rating=3)
|
||||||
self.assertEqual(bookwyrm_tags.get_user_rating(self.book, self.user), 3)
|
self.assertEqual(bookwyrm_tags.get_user_rating(self.book, self.user), 3)
|
||||||
|
@ -63,12 +60,9 @@ class TemplateTags(TestCase):
|
||||||
utilities.get_user_identifier(self.remote_user), "rat@example.com"
|
utilities.get_user_identifier(self.remote_user), "rat@example.com"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||||
def test_get_replies(self, *_):
|
def test_get_replies(self, *_):
|
||||||
"""direct replies to a status"""
|
"""direct replies to a status"""
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
|
||||||
parent = models.Review.objects.create(
|
parent = models.Review.objects.create(
|
||||||
user=self.user, book=self.book, content="hi"
|
user=self.user, book=self.book, content="hi"
|
||||||
)
|
)
|
||||||
|
@ -97,9 +91,6 @@ class TemplateTags(TestCase):
|
||||||
def test_get_parent(self, *_):
|
def test_get_parent(self, *_):
|
||||||
"""get the reply parent of a status"""
|
"""get the reply parent of a status"""
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
|
||||||
parent = models.Review.objects.create(
|
parent = models.Review.objects.create(
|
||||||
user=self.user, book=self.book, content="hi"
|
user=self.user, book=self.book, content="hi"
|
||||||
)
|
)
|
||||||
|
@ -113,7 +104,6 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_user_liked(self, *_):
|
def test_get_user_liked(self, *_):
|
||||||
"""did a user like a status"""
|
"""did a user like a status"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
status = models.Review.objects.create(user=self.remote_user, book=self.book)
|
status = models.Review.objects.create(user=self.remote_user, book=self.book)
|
||||||
|
|
||||||
self.assertFalse(interaction.get_user_liked(self.user, status))
|
self.assertFalse(interaction.get_user_liked(self.user, status))
|
||||||
|
@ -123,7 +113,6 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_user_boosted(self, *_):
|
def test_get_user_boosted(self, *_):
|
||||||
"""did a user boost a status"""
|
"""did a user boost a status"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
status = models.Review.objects.create(user=self.remote_user, book=self.book)
|
status = models.Review.objects.create(user=self.remote_user, book=self.book)
|
||||||
|
|
||||||
self.assertFalse(interaction.get_user_boosted(self.user, status))
|
self.assertFalse(interaction.get_user_boosted(self.user, status))
|
||||||
|
@ -133,7 +122,6 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_boosted(self, *_):
|
def test_get_boosted(self, *_):
|
||||||
"""load a boosted status"""
|
"""load a boosted status"""
|
||||||
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"):
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
user=self.remote_user, book=self.book
|
user=self.remote_user, book=self.book
|
||||||
|
@ -147,7 +135,6 @@ 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"""
|
||||||
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")
|
||||||
self.book.parent_work = work
|
self.book.parent_work = work
|
||||||
self.book.save()
|
self.book.save()
|
||||||
|
|
|
@ -19,7 +19,6 @@ class Inbox(TestCase):
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
local_user = models.User.objects.create_user(
|
local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -47,7 +46,6 @@ class Inbox(TestCase):
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_inbox_invalid_get(self):
|
def test_inbox_invalid_get(self):
|
||||||
|
|
|
@ -13,7 +13,6 @@ class InboxAdd(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
local_user = models.User.objects.create_user(
|
local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -33,14 +32,14 @@ class InboxAdd(TestCase):
|
||||||
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"):
|
|
||||||
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(
|
||||||
title="Test",
|
title="Test",
|
||||||
remote_id="https://example.com/book/37292",
|
remote_id="https://example.com/book/37292",
|
||||||
parent_work=work,
|
parent_work=work,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
|
|
|
@ -13,7 +13,6 @@ class InboxActivities(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -33,7 +32,7 @@ class InboxActivities(TestCase):
|
||||||
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.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(
|
||||||
|
@ -50,7 +49,7 @@ class InboxActivities(TestCase):
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
||||||
|
@ -88,7 +87,6 @@ class InboxActivities(TestCase):
|
||||||
@patch("bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores")
|
@patch("bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores")
|
||||||
def test_boost_remote_status(self, redis_mock, _):
|
def test_boost_remote_status(self, redis_mock, _):
|
||||||
"""boost a status from a remote server"""
|
"""boost a status from a remote server"""
|
||||||
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")
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
title="Test",
|
title="Test",
|
||||||
|
|
|
@ -12,7 +12,6 @@ class InboxBlock(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -32,7 +31,7 @@ class InboxBlock(TestCase):
|
||||||
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"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_handle_blocks(self):
|
def test_handle_blocks(self):
|
||||||
|
|
|
@ -15,7 +15,6 @@ class InboxCreate(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -35,7 +34,6 @@ class InboxCreate(TestCase):
|
||||||
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.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.local_user,
|
user=self.local_user,
|
||||||
|
@ -51,7 +49,6 @@ class InboxCreate(TestCase):
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_create_status(self):
|
def test_create_status(self):
|
||||||
|
@ -63,7 +60,6 @@ class InboxCreate(TestCase):
|
||||||
)
|
)
|
||||||
status_data = json.loads(datafile.read_bytes())
|
status_data = json.loads(datafile.read_bytes())
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
models.Edition.objects.create(
|
models.Edition.objects.create(
|
||||||
title="Test Book", remote_id="https://example.com/book/1"
|
title="Test Book", remote_id="https://example.com/book/1"
|
||||||
)
|
)
|
||||||
|
@ -133,7 +129,6 @@ class InboxCreate(TestCase):
|
||||||
|
|
||||||
def test_create_rating(self):
|
def test_create_rating(self):
|
||||||
"""a remote rating activity"""
|
"""a remote rating activity"""
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
title="Test Book", remote_id="https://example.com/book/1"
|
title="Test Book", remote_id="https://example.com/book/1"
|
||||||
)
|
)
|
||||||
|
@ -162,7 +157,6 @@ class InboxCreate(TestCase):
|
||||||
"rating": 3,
|
"rating": 3,
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
}
|
}
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.activitystreams.ActivityStream.add_status"
|
"bookwyrm.activitystreams.ActivityStream.add_status"
|
||||||
) as redis_mock:
|
) as redis_mock:
|
||||||
|
|
|
@ -13,7 +13,6 @@ class InboxActivities(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -48,7 +47,6 @@ class InboxActivities(TestCase):
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_delete_status(self):
|
def test_delete_status(self):
|
||||||
|
@ -119,7 +117,6 @@ class InboxActivities(TestCase):
|
||||||
"object": self.remote_user.remote_id,
|
"object": self.remote_user.remote_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
views.inbox.activity_task(activity)
|
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)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ class InboxRelationships(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -34,7 +33,6 @@ class InboxRelationships(TestCase):
|
||||||
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"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_follow(self):
|
def test_follow(self):
|
||||||
|
|
|
@ -12,7 +12,6 @@ class InboxActivities(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -50,7 +49,6 @@ class InboxActivities(TestCase):
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_handle_favorite(self):
|
def test_handle_favorite(self):
|
||||||
|
|
|
@ -12,7 +12,6 @@ class InboxRemove(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -33,7 +32,6 @@ class InboxRemove(TestCase):
|
||||||
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"):
|
|
||||||
self.work = models.Work.objects.create(title="work title")
|
self.work = models.Work.objects.create(title="work title")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Test",
|
title="Test",
|
||||||
|
@ -41,7 +39,6 @@ class InboxRemove(TestCase):
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_handle_unshelve_book(self):
|
def test_handle_unshelve_book(self):
|
||||||
|
|
|
@ -14,7 +14,6 @@ class InboxUpdate(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@example.com",
|
"mouse@example.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -43,7 +42,7 @@ class InboxUpdate(TestCase):
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_update_list(self):
|
def test_update_list(self):
|
||||||
|
@ -99,7 +98,6 @@ class InboxUpdate(TestCase):
|
||||||
self.assertIsNone(self.remote_user.name)
|
self.assertIsNone(self.remote_user.name)
|
||||||
self.assertFalse(self.remote_user.discoverable)
|
self.assertFalse(self.remote_user.discoverable)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
views.inbox.activity_task(
|
views.inbox.activity_task(
|
||||||
{
|
{
|
||||||
"type": "Update",
|
"type": "Update",
|
||||||
|
@ -124,7 +122,6 @@ class InboxUpdate(TestCase):
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../../data/bw_edition.json")
|
datafile = pathlib.Path(__file__).parent.joinpath("../../data/bw_edition.json")
|
||||||
bookdata = json.loads(datafile.read_bytes())
|
bookdata = json.loads(datafile.read_bytes())
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
models.Work.objects.create(
|
models.Work.objects.create(
|
||||||
title="Test Work", remote_id="https://bookwyrm.social/book/5988"
|
title="Test Work", remote_id="https://bookwyrm.social/book/5988"
|
||||||
)
|
)
|
||||||
|
@ -155,7 +152,6 @@ class InboxUpdate(TestCase):
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../../data/bw_work.json")
|
datafile = pathlib.Path(__file__).parent.joinpath("../../data/bw_work.json")
|
||||||
bookdata = json.loads(datafile.read_bytes())
|
bookdata = json.loads(datafile.read_bytes())
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
book = models.Work.objects.create(
|
book = models.Work.objects.create(
|
||||||
title="Test Book", remote_id="https://bookwyrm.social/book/5988"
|
title="Test Book", remote_id="https://bookwyrm.social/book/5988"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
|
|
||||||
|
@ -13,7 +12,6 @@ class AnnouncementViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -21,7 +19,7 @@ class AnnouncementViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_announcements_page(self):
|
def test_announcements_page(self):
|
||||||
|
|
|
@ -19,7 +19,6 @@ class AuthenticationViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -29,7 +28,7 @@ class AuthenticationViews(TestCase):
|
||||||
)
|
)
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
self.settings = models.SiteSettings.objects.create(id=1)
|
self.settings = models.SiteSettings.objects.create(id=1)
|
||||||
|
|
||||||
def test_login_get(self):
|
def test_login_get(self):
|
||||||
|
@ -60,7 +59,6 @@ class AuthenticationViews(TestCase):
|
||||||
"email": "aa@bb.cccc",
|
"email": "aa@bb.cccc",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.views.authentication.login"):
|
with patch("bookwyrm.views.authentication.login"):
|
||||||
response = view(request)
|
response = view(request)
|
||||||
self.assertEqual(models.User.objects.count(), 2)
|
self.assertEqual(models.User.objects.count(), 2)
|
||||||
|
@ -77,7 +75,6 @@ class AuthenticationViews(TestCase):
|
||||||
"register/",
|
"register/",
|
||||||
{"localname": "nutria ", "password": "mouseword", "email": "aa@bb.ccc"},
|
{"localname": "nutria ", "password": "mouseword", "email": "aa@bb.ccc"},
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.views.authentication.login"):
|
with patch("bookwyrm.views.authentication.login"):
|
||||||
response = view(request)
|
response = view(request)
|
||||||
self.assertEqual(models.User.objects.count(), 2)
|
self.assertEqual(models.User.objects.count(), 2)
|
||||||
|
@ -157,7 +154,6 @@ class AuthenticationViews(TestCase):
|
||||||
"invite_code": "testcode",
|
"invite_code": "testcode",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.views.authentication.login"):
|
with patch("bookwyrm.views.authentication.login"):
|
||||||
response = view(request)
|
response = view(request)
|
||||||
self.assertEqual(models.User.objects.count(), 2)
|
self.assertEqual(models.User.objects.count(), 2)
|
||||||
|
|
|
@ -17,7 +17,6 @@ class AuthorViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -34,14 +33,13 @@ class AuthorViews(TestCase):
|
||||||
content_type=ContentType.objects.get_for_model(models.User),
|
content_type=ContentType.objects.get_for_model(models.User),
|
||||||
).id
|
).id
|
||||||
)
|
)
|
||||||
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(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
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.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_author_page(self):
|
def test_author_page(self):
|
||||||
|
|
|
@ -14,7 +14,6 @@ class BlockViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -32,7 +31,7 @@ class BlockViews(TestCase):
|
||||||
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"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_block_get(self, _):
|
def test_block_get(self, _):
|
||||||
|
|
|
@ -23,7 +23,6 @@ class BookViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -40,14 +39,13 @@ class BookViews(TestCase):
|
||||||
content_type=ContentType.objects.get_for_model(models.User),
|
content_type=ContentType.objects.get_for_model(models.User),
|
||||||
).id
|
).id
|
||||||
)
|
)
|
||||||
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(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
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.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_book_page(self):
|
def test_book_page(self):
|
||||||
|
@ -74,7 +72,6 @@ class BookViews(TestCase):
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
request.user.is_superuser = True
|
request.user.is_superuser = True
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
result = view(request, self.book.id)
|
result = view(request, self.book.id)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
result.render()
|
result.render()
|
||||||
|
@ -90,7 +87,6 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
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"):
|
||||||
view(request, self.book.id)
|
view(request, self.book.id)
|
||||||
|
|
||||||
|
@ -108,7 +104,6 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
result = view(request, self.book.id)
|
result = view(request, self.book.id)
|
||||||
result.render()
|
result.render()
|
||||||
|
|
||||||
|
@ -128,7 +123,6 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
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"):
|
||||||
view(request, self.book.id)
|
view(request, self.book.id)
|
||||||
|
|
||||||
|
@ -150,7 +144,6 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
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"):
|
||||||
view(request, self.book.id)
|
view(request, self.book.id)
|
||||||
self.book.refresh_from_db()
|
self.book.refresh_from_db()
|
||||||
|
@ -167,8 +160,8 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
view(request)
|
view(request)
|
||||||
|
|
||||||
book = models.Edition.objects.get(title="New Title")
|
book = models.Edition.objects.get(title="New Title")
|
||||||
self.assertEqual(book.parent_work.title, "New Title")
|
self.assertEqual(book.parent_work.title, "New Title")
|
||||||
|
|
||||||
|
@ -183,8 +176,8 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
view(request)
|
view(request)
|
||||||
|
|
||||||
book = models.Edition.objects.get(title="New Title")
|
book = models.Edition.objects.get(title="New Title")
|
||||||
self.assertEqual(book.parent_work, self.work)
|
self.assertEqual(book.parent_work, self.work)
|
||||||
|
|
||||||
|
@ -200,8 +193,8 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
view(request)
|
view(request)
|
||||||
|
|
||||||
book = models.Edition.objects.get(title="New Title")
|
book = models.Edition.objects.get(title="New Title")
|
||||||
self.assertEqual(book.parent_work.title, "New Title")
|
self.assertEqual(book.parent_work.title, "New Title")
|
||||||
self.assertEqual(book.authors.first().name, "Sappho")
|
self.assertEqual(book.authors.first().name, "Sappho")
|
||||||
|
@ -210,7 +203,6 @@ class BookViews(TestCase):
|
||||||
def test_switch_edition(self):
|
def test_switch_edition(self):
|
||||||
"""updates user's relationships to a book"""
|
"""updates user's relationships to a book"""
|
||||||
work = models.Work.objects.create(title="test work")
|
work = models.Work.objects.create(title="test work")
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
edition1 = models.Edition.objects.create(title="first ed", parent_work=work)
|
edition1 = models.Edition.objects.create(title="first ed", parent_work=work)
|
||||||
edition2 = models.Edition.objects.create(
|
edition2 = models.Edition.objects.create(
|
||||||
title="second ed", parent_work=work
|
title="second ed", parent_work=work
|
||||||
|
@ -267,7 +259,6 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||||
) as delay_mock:
|
) as delay_mock:
|
||||||
|
@ -300,7 +291,6 @@ class BookViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||||
) as delay_mock:
|
) as delay_mock:
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
|
|
||||||
|
@ -13,7 +12,6 @@ class DirectoryViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -31,7 +29,7 @@ class DirectoryViews(TestCase):
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
discoverable=True,
|
discoverable=True,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_directory_page(self):
|
def test_directory_page(self):
|
||||||
|
|
|
@ -21,7 +21,6 @@ class EditUserViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -33,7 +32,6 @@ class EditUserViews(TestCase):
|
||||||
"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.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.book = models.Edition.objects.create(title="test")
|
self.book = models.Edition.objects.create(title="test")
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
models.ShelfBook.objects.create(
|
models.ShelfBook.objects.create(
|
||||||
|
@ -42,7 +40,6 @@ class EditUserViews(TestCase):
|
||||||
shelf=self.local_user.shelf_set.first(),
|
shelf=self.local_user.shelf_set.first(),
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
|
@ -68,7 +65,6 @@ class EditUserViews(TestCase):
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
self.assertIsNone(self.local_user.name)
|
self.assertIsNone(self.local_user.name)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||||
) as delay_mock:
|
) as delay_mock:
|
||||||
|
@ -93,7 +89,6 @@ class EditUserViews(TestCase):
|
||||||
request = self.factory.post("", form.data)
|
request = self.factory.post("", form.data)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||||
) as delay_mock:
|
) as delay_mock:
|
||||||
|
|
|
@ -15,7 +15,6 @@ class FederationViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -33,7 +32,7 @@ class FederationViews(TestCase):
|
||||||
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"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_federation_page(self):
|
def test_federation_page(self):
|
||||||
|
|
|
@ -22,7 +22,6 @@ class FeedViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -30,13 +29,11 @@ class FeedViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
parent_work=models.Work.objects.create(title="hi"),
|
parent_work=models.Work.objects.create(title="hi"),
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_feed(self, *_):
|
def test_feed(self, *_):
|
||||||
|
@ -92,9 +89,6 @@ class FeedViews(TestCase):
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
image.save(output, format=image.format)
|
image.save(output, format=image.format)
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
content="hi",
|
content="hi",
|
||||||
user=self.local_user,
|
user=self.local_user,
|
||||||
|
@ -152,7 +146,6 @@ class FeedViews(TestCase):
|
||||||
|
|
||||||
def test_get_suggested_book(self, *_):
|
def test_get_suggested_book(self, *_):
|
||||||
"""gets books the ~*~ algorithm ~*~ thinks you want to post about"""
|
"""gets books the ~*~ algorithm ~*~ thinks you want to post about"""
|
||||||
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"):
|
||||||
models.ShelfBook.objects.create(
|
models.ShelfBook.objects.create(
|
||||||
book=self.book,
|
book=self.book,
|
||||||
|
|
|
@ -16,7 +16,6 @@ class BookViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -43,7 +42,6 @@ class BookViews(TestCase):
|
||||||
content_type=ContentType.objects.get_for_model(models.User),
|
content_type=ContentType.objects.get_for_model(models.User),
|
||||||
).id
|
).id
|
||||||
)
|
)
|
||||||
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(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -68,7 +66,6 @@ class BookViews(TestCase):
|
||||||
|
|
||||||
def test_handle_follow_local_manually_approves(self):
|
def test_handle_follow_local_manually_approves(self):
|
||||||
"""send a follow request"""
|
"""send a follow request"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
rat = models.User.objects.create_user(
|
rat = models.User.objects.create_user(
|
||||||
"rat@local.com",
|
"rat@local.com",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
|
@ -92,7 +89,6 @@ class BookViews(TestCase):
|
||||||
|
|
||||||
def test_handle_follow_local(self):
|
def test_handle_follow_local(self):
|
||||||
"""send a follow request"""
|
"""send a follow request"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
rat = models.User.objects.create_user(
|
rat = models.User.objects.create_user(
|
||||||
"rat@local.com",
|
"rat@local.com",
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
|
|
|
@ -13,7 +13,6 @@ class GetStartedViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -21,7 +20,6 @@ class GetStartedViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
parent_work=models.Work.objects.create(title="hi"),
|
parent_work=models.Work.objects.create(title="hi"),
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -30,7 +28,6 @@ class GetStartedViews(TestCase):
|
||||||
models.Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="self", connector_file="self_connector", local=True
|
identifier="self", connector_file="self_connector", local=True
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_profile_view(self):
|
def test_profile_view(self):
|
||||||
|
@ -55,7 +52,6 @@ class GetStartedViews(TestCase):
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
self.assertIsNone(self.local_user.name)
|
self.assertIsNone(self.local_user.name)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
|
||||||
) as delay_mock:
|
) as delay_mock:
|
||||||
|
|
|
@ -16,7 +16,6 @@ class GoalViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -33,14 +32,12 @@ class GoalViews(TestCase):
|
||||||
localname="rat",
|
localname="rat",
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
)
|
)
|
||||||
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",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
)
|
)
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_goal_page_no_goal(self):
|
def test_goal_page_no_goal(self):
|
||||||
|
|
|
@ -19,7 +19,6 @@ class ViewsHelpers(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -40,7 +39,6 @@ class ViewsHelpers(TestCase):
|
||||||
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"):
|
|
||||||
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(
|
||||||
title="Test Book",
|
title="Test Book",
|
||||||
|
@ -144,7 +142,6 @@ class ViewsHelpers(TestCase):
|
||||||
json=self.userdata,
|
json=self.userdata,
|
||||||
status=200,
|
status=200,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
result = views.helpers.handle_remote_webfinger("@mouse@example.com")
|
result = views.helpers.handle_remote_webfinger("@mouse@example.com")
|
||||||
self.assertIsInstance(result, models.User)
|
self.assertIsInstance(result, models.User)
|
||||||
|
@ -205,7 +202,6 @@ class ViewsHelpers(TestCase):
|
||||||
|
|
||||||
def test_get_annotated_users(self, _):
|
def test_get_annotated_users(self, _):
|
||||||
"""list of people you might know"""
|
"""list of people you might know"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user_1 = models.User.objects.create_user(
|
user_1 = models.User.objects.create_user(
|
||||||
"nutria@local.com",
|
"nutria@local.com",
|
||||||
"nutria@nutria.com",
|
"nutria@nutria.com",
|
||||||
|
@ -253,7 +249,6 @@ class ViewsHelpers(TestCase):
|
||||||
|
|
||||||
def test_get_annotated_users_counts(self, _):
|
def test_get_annotated_users_counts(self, _):
|
||||||
"""correct counting for multiple shared attributed"""
|
"""correct counting for multiple shared attributed"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user_1 = models.User.objects.create_user(
|
user_1 = models.User.objects.create_user(
|
||||||
"nutria@local.com",
|
"nutria@local.com",
|
||||||
"nutria@nutria.com",
|
"nutria@nutria.com",
|
||||||
|
@ -262,7 +257,6 @@ class ViewsHelpers(TestCase):
|
||||||
localname="nutria",
|
localname="nutria",
|
||||||
discoverable=True,
|
discoverable=True,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
user = models.User.objects.create_user(
|
user = models.User.objects.create_user(
|
||||||
"{:d}@local.com".format(i),
|
"{:d}@local.com".format(i),
|
||||||
|
@ -274,7 +268,6 @@ class ViewsHelpers(TestCase):
|
||||||
user.following.add(user_1)
|
user.following.add(user_1)
|
||||||
user.followers.add(self.local_user)
|
user.followers.add(self.local_user)
|
||||||
|
|
||||||
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"):
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
book = models.Edition.objects.create(
|
book = models.Edition.objects.create(
|
||||||
|
|
|
@ -14,7 +14,6 @@ class ImportViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -22,7 +21,6 @@ class ImportViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_import_page(self):
|
def test_import_page(self):
|
||||||
|
|
|
@ -15,7 +15,6 @@ class InteractionViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -35,7 +34,6 @@ class InteractionViews(TestCase):
|
||||||
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"):
|
|
||||||
work = models.Work.objects.create(title="Test Work")
|
work = models.Work.objects.create(title="Test Work")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
|
|
@ -16,7 +16,6 @@ class InviteViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -24,7 +23,6 @@ class InviteViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_invite_page(self):
|
def test_invite_page(self):
|
||||||
|
|
|
@ -16,7 +16,6 @@ class IsbnViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -25,7 +24,6 @@ class IsbnViews(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
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(
|
||||||
title="Test Book",
|
title="Test Book",
|
||||||
|
@ -36,7 +34,6 @@ class IsbnViews(TestCase):
|
||||||
models.Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="self", connector_file="self_connector", local=True
|
identifier="self", connector_file="self_connector", local=True
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_isbn_json_response(self):
|
def test_isbn_json_response(self):
|
||||||
|
|
|
@ -15,7 +15,6 @@ class LandingViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -25,7 +24,6 @@ class LandingViews(TestCase):
|
||||||
)
|
)
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_home_page(self):
|
def test_home_page(self):
|
||||||
|
|
|
@ -17,7 +17,6 @@ class ListViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -34,7 +33,6 @@ class ListViews(TestCase):
|
||||||
localname="rat",
|
localname="rat",
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
work = models.Work.objects.create(title="Work")
|
work = models.Work.objects.create(title="Work")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -66,7 +64,7 @@ class ListViews(TestCase):
|
||||||
)
|
)
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_lists_page(self):
|
def test_lists_page(self):
|
||||||
|
|
|
@ -15,7 +15,6 @@ class ListActionViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -33,7 +32,6 @@ class ListActionViews(TestCase):
|
||||||
remote_id="https://example.com/users/rat",
|
remote_id="https://example.com/users/rat",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
work = models.Work.objects.create(title="Work")
|
work = models.Work.objects.create(title="Work")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -65,7 +63,6 @@ class ListActionViews(TestCase):
|
||||||
)
|
)
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_curate_approve(self):
|
def test_curate_approve(self):
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from bookwyrm import views
|
from bookwyrm import views
|
||||||
|
@ -14,7 +13,6 @@ class NotificationViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -22,7 +20,6 @@ class NotificationViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_notifications_page(self):
|
def test_notifications_page(self):
|
||||||
|
|
|
@ -18,7 +18,6 @@ class OutboxView(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we'll need some data"""
|
"""we'll need some data"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -27,7 +26,6 @@ class OutboxView(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
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")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -81,9 +79,6 @@ class OutboxView(TestCase):
|
||||||
def test_outbox_filter(self, _):
|
def test_outbox_filter(self, _):
|
||||||
"""if we only care about reviews, only get reviews"""
|
"""if we only care about reviews, only get reviews"""
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
|
||||||
models.Review.objects.create(
|
models.Review.objects.create(
|
||||||
content="look at this",
|
content="look at this",
|
||||||
name="hi",
|
name="hi",
|
||||||
|
@ -110,9 +105,6 @@ class OutboxView(TestCase):
|
||||||
def test_outbox_bookwyrm_request_true(self, _):
|
def test_outbox_bookwyrm_request_true(self, _):
|
||||||
"""should differentiate between bookwyrm and outside requests"""
|
"""should differentiate between bookwyrm and outside requests"""
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
|
||||||
models.Review.objects.create(
|
models.Review.objects.create(
|
||||||
name="hi",
|
name="hi",
|
||||||
content="look at this",
|
content="look at this",
|
||||||
|
@ -131,9 +123,6 @@ class OutboxView(TestCase):
|
||||||
def test_outbox_bookwyrm_request_false(self, _):
|
def test_outbox_bookwyrm_request_false(self, _):
|
||||||
"""should differentiate between bookwyrm and outside requests"""
|
"""should differentiate between bookwyrm and outside requests"""
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
|
||||||
models.Review.objects.create(
|
models.Review.objects.create(
|
||||||
name="hi",
|
name="hi",
|
||||||
content="look at this",
|
content="look at this",
|
||||||
|
|
|
@ -15,7 +15,6 @@ class PasswordViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -25,7 +24,6 @@ class PasswordViews(TestCase):
|
||||||
)
|
)
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create(id=1)
|
models.SiteSettings.objects.create(id=1)
|
||||||
|
|
||||||
def test_password_reset_request(self):
|
def test_password_reset_request(self):
|
||||||
|
|
|
@ -15,7 +15,6 @@ class ReadingViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -34,7 +33,6 @@ class ReadingViews(TestCase):
|
||||||
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"):
|
|
||||||
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(
|
||||||
title="Test Book",
|
title="Test Book",
|
||||||
|
|
|
@ -15,14 +15,12 @@ class ReadThrough(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.work = models.Work.objects.create(title="Example Work")
|
self.work = models.Work.objects.create(title="Example Work")
|
||||||
|
|
||||||
self.edition = models.Edition.objects.create(
|
self.edition = models.Edition.objects.create(
|
||||||
title="Example Edition", parent_work=self.work
|
title="Example Edition", parent_work=self.work
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"cinco", "cinco@example.com", "seissiete", local=True, localname="cinco"
|
"cinco", "cinco@example.com", "seissiete", local=True, localname="cinco"
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from bookwyrm import forms, models, views
|
from bookwyrm import forms, models, views
|
||||||
|
|
||||||
|
@ -13,7 +12,6 @@ class ReportViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -28,7 +26,6 @@ class ReportViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="rat",
|
localname="rat",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_reports_page(self):
|
def test_reports_page(self):
|
||||||
|
|
|
@ -12,15 +12,12 @@ class RssFeedView(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""test data"""
|
"""test data"""
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
self.site = models.SiteSettings.objects.create()
|
self.site = models.SiteSettings.objects.create()
|
||||||
|
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"rss_user", "rss@test.rss", "password", local=True
|
"rss_user", "rss@test.rss", "password", local=True
|
||||||
)
|
)
|
||||||
|
|
||||||
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")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -30,9 +27,6 @@ class RssFeedView(TestCase):
|
||||||
|
|
||||||
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"):
|
||||||
with patch(
|
|
||||||
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
|
|
||||||
):
|
|
||||||
self.review = models.Review.objects.create(
|
self.review = models.Review.objects.create(
|
||||||
name="Review name",
|
name="Review name",
|
||||||
content="test content",
|
content="test content",
|
||||||
|
|
|
@ -19,7 +19,6 @@ class Views(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -28,7 +27,6 @@ class Views(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
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(
|
||||||
title="Test Book",
|
title="Test Book",
|
||||||
|
@ -38,7 +36,6 @@ class Views(TestCase):
|
||||||
models.Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="self", connector_file="self_connector", local=True
|
identifier="self", connector_file="self_connector", local=True
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_search_json_response(self):
|
def test_search_json_response(self):
|
||||||
|
|
|
@ -16,7 +16,6 @@ class ShelfViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -25,7 +24,6 @@ class ShelfViews(TestCase):
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
remote_id="https://example.com/users/mouse",
|
remote_id="https://example.com/users/mouse",
|
||||||
)
|
)
|
||||||
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(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
@ -36,7 +34,6 @@ class ShelfViews(TestCase):
|
||||||
self.shelf = models.Shelf.objects.create(
|
self.shelf = models.Shelf.objects.create(
|
||||||
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
name="Test Shelf", identifier="test-shelf", user=self.local_user
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_shelf_page(self, _):
|
def test_shelf_page(self, _):
|
||||||
|
|
|
@ -16,7 +16,6 @@ class StatusViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.com",
|
"mouse@mouse.com",
|
||||||
|
@ -36,14 +35,12 @@ class StatusViews(TestCase):
|
||||||
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"):
|
|
||||||
work = models.Work.objects.create(title="Test Work")
|
work = models.Work.objects.create(title="Test Work")
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
parent_work=work,
|
parent_work=work,
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_handle_status(self, _):
|
def test_handle_status(self, _):
|
||||||
|
@ -72,7 +69,6 @@ class StatusViews(TestCase):
|
||||||
def test_handle_status_reply(self, _):
|
def test_handle_status_reply(self, _):
|
||||||
"""create a status in reply to an existing status"""
|
"""create a status in reply to an existing status"""
|
||||||
view = views.CreateStatus.as_view()
|
view = views.CreateStatus.as_view()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = models.User.objects.create_user(
|
user = models.User.objects.create_user(
|
||||||
"rat", "rat@rat.com", "password", local=True
|
"rat", "rat@rat.com", "password", local=True
|
||||||
)
|
)
|
||||||
|
@ -103,7 +99,6 @@ class StatusViews(TestCase):
|
||||||
def test_handle_status_mentions(self, _):
|
def test_handle_status_mentions(self, _):
|
||||||
"""@mention a user in a post"""
|
"""@mention a user in a post"""
|
||||||
view = views.CreateStatus.as_view()
|
view = views.CreateStatus.as_view()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = models.User.objects.create_user(
|
user = models.User.objects.create_user(
|
||||||
"rat@%s" % DOMAIN,
|
"rat@%s" % DOMAIN,
|
||||||
"rat@rat.com",
|
"rat@rat.com",
|
||||||
|
@ -136,7 +131,6 @@ class StatusViews(TestCase):
|
||||||
def test_handle_status_reply_with_mentions(self, _):
|
def test_handle_status_reply_with_mentions(self, _):
|
||||||
"""reply to a post with an @mention'ed user"""
|
"""reply to a post with an @mention'ed user"""
|
||||||
view = views.CreateStatus.as_view()
|
view = views.CreateStatus.as_view()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = models.User.objects.create_user(
|
user = models.User.objects.create_user(
|
||||||
"rat", "rat@rat.com", "password", local=True, localname="rat"
|
"rat", "rat@rat.com", "password", local=True, localname="rat"
|
||||||
)
|
)
|
||||||
|
@ -204,7 +198,6 @@ class StatusViews(TestCase):
|
||||||
view = views.DeleteAndRedraft.as_view()
|
view = views.DeleteAndRedraft.as_view()
|
||||||
request = self.factory.post("")
|
request = self.factory.post("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||||
status = models.ReviewRating.objects.create(
|
status = models.ReviewRating.objects.create(
|
||||||
book=self.book, rating=2.0, user=self.local_user
|
book=self.book, rating=2.0, user=self.local_user
|
||||||
|
@ -242,7 +235,6 @@ class StatusViews(TestCase):
|
||||||
|
|
||||||
def test_find_mentions(self, _):
|
def test_find_mentions(self, _):
|
||||||
"""detect and look up @ mentions of users"""
|
"""detect and look up @ mentions of users"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
user = models.User.objects.create_user(
|
user = models.User.objects.create_user(
|
||||||
"nutria@%s" % DOMAIN,
|
"nutria@%s" % DOMAIN,
|
||||||
"nutria@nutria.com",
|
"nutria@nutria.com",
|
||||||
|
|
|
@ -14,7 +14,6 @@ class UpdateViews(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
|
@ -23,7 +22,6 @@ class UpdateViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_get_notification_count(self):
|
def test_get_notification_count(self):
|
||||||
|
|
|
@ -16,7 +16,6 @@ class UserViews(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
|
@ -28,7 +27,6 @@ class UserViews(TestCase):
|
||||||
self.rat = models.User.objects.create_user(
|
self.rat = 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.preview_images.generate_edition_preview_image_task.delay"):
|
|
||||||
self.book = models.Edition.objects.create(title="test")
|
self.book = models.Edition.objects.create(title="test")
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
models.ShelfBook.objects.create(
|
models.ShelfBook.objects.create(
|
||||||
|
@ -37,7 +35,6 @@ class UserViews(TestCase):
|
||||||
shelf=self.local_user.shelf_set.first(),
|
shelf=self.local_user.shelf_set.first(),
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
|
|
|
@ -14,7 +14,6 @@ class UserAdminViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
|
@ -22,7 +21,6 @@ class UserAdminViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
with patch("bookwyrm.preview_images.generate_site_preview_image_task.delay"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_user_admin_list_page(self):
|
def test_user_admin_list_page(self):
|
||||||
|
|
|
@ -15,7 +15,6 @@ class UserViews(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
|
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse@local.com",
|
"mouse@local.com",
|
||||||
|
@ -37,7 +36,6 @@ class UserViews(TestCase):
|
||||||
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"):
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
|
|
Loading…
Reference in a new issue