Fix instances of bad-classmethod-argument in recently edited files

This commit is contained in:
Adeodato Simó 2024-03-17 20:52:20 -03:00
parent 4b9fe0af0c
commit e2c9ea3cd2
117 changed files with 515 additions and 529 deletions

View file

@ -29,18 +29,18 @@ class BaseActivity(TestCase):
"""the super class for model-linked activitypub dataclasses"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we're probably going to re-use this so why copy/paste"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
self.user.remote_id = "http://example.com/a/b"
self.user.save(broadcast=False, update_fields=["remote_id"])
cls.user.remote_id = "http://example.com/a/b"
cls.user.save(broadcast=False, update_fields=["remote_id"])
def setUp(self):
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")

View file

@ -11,20 +11,20 @@ class Note(TestCase):
"""the model-linked ActivityPub dataclass for Note-based types"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create a shared user"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
self.user.remote_id = "https://test-instance.org/user/critic"
self.user.save(broadcast=False, update_fields=["remote_id"])
cls.user.remote_id = "https://test-instance.org/user/critic"
cls.user.save(broadcast=False, update_fields=["remote_id"])
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Test Edition", remote_id="http://book.com/book"
)

View file

@ -16,17 +16,17 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""use a test csv"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -34,7 +34,7 @@ class Activitystreams(TestCase):
localname="nutria",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -44,7 +44,7 @@ class Activitystreams(TestCase):
outbox="https://example.com/users/rat/outbox",
)
work = models.Work.objects.create(title="test work")
self.book = models.Edition.objects.create(title="test book", parent_work=work)
cls.book = models.Edition.objects.create(title="test book", parent_work=work)
def setUp(self):
"""per-test setUp"""

View file

@ -15,18 +15,18 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""use a test csv"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -36,7 +36,7 @@ class Activitystreams(TestCase):
outbox="https://example.com/users/rat/outbox",
)
work = models.Work.objects.create(title="test work")
self.book = models.Edition.objects.create(title="test book", parent_work=work)
cls.book = models.Edition.objects.create(title="test book", parent_work=work)
def test_get_statuses_for_user_books(self, *_):
"""create a stream for a user"""

View file

@ -13,17 +13,17 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""use a test csv"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -31,7 +31,7 @@ class Activitystreams(TestCase):
localname="nutria",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -13,17 +13,17 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""use a test csv"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -31,7 +31,7 @@ class Activitystreams(TestCase):
localname="nutria",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -41,7 +41,7 @@ class Activitystreams(TestCase):
outbox="https://example.com/users/rat/outbox",
)
work = models.Work.objects.create(title="test work")
self.book = models.Edition.objects.create(title="test book", parent_work=work)
cls.book = models.Edition.objects.create(title="test book", parent_work=work)
def test_localstream_get_audience_remote_status(self, *_):
"""get a list of users that should see a status"""

View file

@ -15,18 +15,18 @@ class ActivitystreamsSignals(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""use a test csv"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -8,17 +8,17 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""use a test csv"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -26,7 +26,7 @@ class Activitystreams(TestCase):
localname="nutria",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -36,11 +36,9 @@ class Activitystreams(TestCase):
outbox="https://example.com/users/rat/outbox",
)
work = models.Work.objects.create(title="test work")
self.book = models.Edition.objects.create(title="test book", parent_work=work)
cls.book = models.Edition.objects.create(title="test book", parent_work=work)
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
self.status = models.Status.objects.create(
content="hi", user=self.local_user
)
cls.status = models.Status.objects.create(content="hi", user=cls.local_user)
def test_add_book_statuses_task(self):
"""statuses related to a book"""

View file

@ -15,7 +15,7 @@ class Inventaire(TestCase):
"""test loading data from inventaire.io"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""creates the connector in the database"""
models.Connector.objects.create(
identifier="inventaire.io",

View file

@ -23,19 +23,19 @@ class CalibreImport(TestCase):
self.csv = open(datafile, "r", encoding=self.importer.encoding)
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""populate database"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True
)
models.SiteSettings.objects.create()
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,

View file

@ -30,19 +30,19 @@ class GoodreadsImport(TestCase):
self.csv = open(datafile, "r", encoding=self.importer.encoding)
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""populate database"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True
)
models.SiteSettings.objects.create()
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,

View file

@ -33,19 +33,19 @@ class GenericImporter(TestCase):
self.csv = open(datafile, "r", encoding=self.importer.encoding)
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""populate database"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True
)
models.SiteSettings.objects.create()
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,

View file

@ -32,19 +32,19 @@ class LibrarythingImport(TestCase):
self.csv = open(datafile, "r", encoding=self.importer.encoding)
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""populate database"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mmai", "mmai@mmai.mmai", "password", local=True
)
models.SiteSettings.objects.create()
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,

View file

@ -30,19 +30,19 @@ class OpenLibraryImport(TestCase):
self.csv = open(datafile, "r", encoding=self.importer.encoding)
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""populate database"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True
)
models.SiteSettings.objects.create()
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,

View file

@ -30,19 +30,19 @@ class StorygraphImport(TestCase):
self.csv = open(datafile, "r", encoding=self.importer.encoding)
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""populate database"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True
)
models.SiteSettings.objects.create()
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,

View file

@ -9,21 +9,21 @@ class ListsStreamSignals(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""database setup"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"fish", "fish@fish.fish", "password", local=True, localname="fish"
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -16,17 +16,17 @@ class ListsStream(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""database setup"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -34,7 +34,7 @@ class ListsStream(TestCase):
localname="nutria",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -43,7 +43,7 @@ class ListsStream(TestCase):
inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox",
)
self.stream = lists_stream.ListsStream()
cls.stream = lists_stream.ListsStream()
def test_lists_stream_ids(self, *_):
"""the abstract base class for stream objects"""

View file

@ -11,17 +11,17 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""database setup"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -29,7 +29,7 @@ class Activitystreams(TestCase):
localname="nutria",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -42,8 +42,8 @@ class Activitystreams(TestCase):
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create(
user=self.local_user, name="hi", privacy="public"
cls.list = models.List.objects.create(
user=cls.local_user, name="hi", privacy="public"
)
def test_populate_lists_task(self, *_):

View file

@ -13,17 +13,17 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need some stuff"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -39,7 +39,7 @@ class Activitystreams(TestCase):
is_active=False,
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -48,7 +48,7 @@ class Activitystreams(TestCase):
inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox",
)
self.book = models.Edition.objects.create(title="test book")
cls.book = models.Edition.objects.create(title="test book")
def test_populate_streams(self, *_):
"""make sure the function on the redis manager gets called"""

View file

@ -11,17 +11,17 @@ class Activitystreams(TestCase):
"""using redis to build activity streams"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need some stuff"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria",
"nutria@nutria.nutria",
"password",
@ -37,7 +37,7 @@ class Activitystreams(TestCase):
is_active=False,
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -46,7 +46,7 @@ class Activitystreams(TestCase):
inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox",
)
self.book = models.Edition.objects.create(title="test book")
cls.book = models.Edition.objects.create(title="test book")
def test_populate_streams(self, _):
"""make sure the function on the redis manager gets called"""

View file

@ -27,20 +27,20 @@ class ActivitypubMixins(TestCase):
"""functionality shared across models"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""shared data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
)
self.local_user.remote_id = "http://example.com/a/b"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "http://example.com/a/b"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -15,14 +15,14 @@ class AutomodModel(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -13,18 +13,18 @@ class BaseModel(TestCase):
"""functionality shared across models"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""shared data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -10,7 +10,7 @@ class Group(TestCase):
"""some activitypub oddness ahead"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""Set up for tests"""
with (
@ -18,15 +18,15 @@ class Group(TestCase):
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.owner_user = models.User.objects.create_user(
cls.owner_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
self.rat = models.User.objects.create_user(
cls.rat = models.User.objects.create_user(
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
)
self.badger = models.User.objects.create_user(
cls.badger = models.User.objects.create_user(
"badger",
"badger@badger.badger",
"badgerword",
@ -34,7 +34,7 @@ class Group(TestCase):
localname="badger",
)
self.capybara = models.User.objects.create_user(
cls.capybara = models.User.objects.create_user(
"capybara",
"capybara@capybara.capybara",
"capybaraword",
@ -42,32 +42,32 @@ class Group(TestCase):
localname="capybara",
)
self.public_group = models.Group.objects.create(
cls.public_group = models.Group.objects.create(
name="Public Group",
description="Initial description",
user=self.owner_user,
user=cls.owner_user,
privacy="public",
)
self.private_group = models.Group.objects.create(
cls.private_group = models.Group.objects.create(
name="Private Group",
description="Top secret",
user=self.owner_user,
user=cls.owner_user,
privacy="direct",
)
self.followers_only_group = models.Group.objects.create(
cls.followers_only_group = models.Group.objects.create(
name="Followers Group",
description="No strangers",
user=self.owner_user,
user=cls.owner_user,
privacy="followers",
)
models.GroupMember.objects.create(group=self.private_group, user=self.badger)
models.GroupMember.objects.create(group=cls.private_group, user=cls.badger)
models.GroupMember.objects.create(
group=self.followers_only_group, user=self.badger
group=cls.followers_only_group, user=cls.badger
)
models.GroupMember.objects.create(group=self.public_group, user=self.capybara)
models.GroupMember.objects.create(group=cls.public_group, user=cls.capybara)
def test_group_members_can_see_private_groups(self, _):
"""direct privacy group should not be excluded from group listings for group

View file

@ -17,14 +17,14 @@ class ImportJob(TestCase):
"""this is a fancy one!!!"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""data is from a goodreads export of The Raven Tower"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True
)

View file

@ -12,18 +12,18 @@ class List(TestCase):
"""some activitypub oddness ahead"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""look, a list"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
work = models.Work.objects.create(title="hello")
self.book = models.Edition.objects.create(title="hi", parent_work=work)
cls.book = models.Edition.objects.create(title="hi", parent_work=work)
def test_remote_id(self, *_):
"""shelves use custom remote ids"""

View file

@ -8,21 +8,21 @@ class Notification(TestCase):
"""let people know things"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""useful things for creating a notification"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"rat", "rat@rat.rat", "ratword", local=True, localname="rat"
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -31,14 +31,14 @@ class Notification(TestCase):
inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox",
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Test Book",
isbn_13="1234567890123",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
self.another_book = models.Edition.objects.create(
cls.another_book = models.Edition.objects.create(
title="Second Test Book",
parent_work=models.Work.objects.create(title="Test Work"),
)
@ -201,14 +201,14 @@ class NotifyInviteRequest(TestCase):
"""let admins know of invite requests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""ensure there is one admin"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -12,20 +12,20 @@ class ReadThrough(TestCase):
"""some activitypub oddness ahead"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""look, a shelf"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
self.work = models.Work.objects.create(title="Example Work")
self.edition = models.Edition.objects.create(
title="Example Edition", parent_work=self.work
cls.work = models.Work.objects.create(title="Example Work")
cls.edition = models.Edition.objects.create(
title="Example Edition", parent_work=cls.work
)
def test_valid_date(self):

View file

@ -15,10 +15,10 @@ class Relationship(TestCase):
"""following, blocking, stuff like that"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need some users for this"""
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -32,11 +32,11 @@ class Relationship(TestCase):
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
)
self.local_user.remote_id = "http://local.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "http://local.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
def test_user_follows(self, *_):
"""basic functionality of user follows"""

View file

@ -16,18 +16,18 @@ class Shelf(TestCase):
"""some activitypub oddness ahead"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""look, a shelf"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(title="test book", parent_work=work)
cls.book = models.Edition.objects.create(title="test book", parent_work=work)
def test_remote_id(self, *_):
"""shelves use custom remote ids"""

View file

@ -13,14 +13,14 @@ class SiteModels(TestCase):
"""tests for site models"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",

View file

@ -25,18 +25,18 @@ class Status(TestCase):
"""lotta types of statuses"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""useful things for creating a status"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -45,7 +45,7 @@ class Status(TestCase):
inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox",
)
self.book = models.Edition.objects.create(title="Test Edition")
cls.book = models.Edition.objects.create(title="Test Edition")
def setUp(self):
"""individual test setup"""

View file

@ -19,13 +19,13 @@ class User(TestCase):
protocol = "https://" if USE_HTTPS else "http://"
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
f"mouse@{DOMAIN}",
"mouse@mouse.mouse",
"mouseword",
@ -35,7 +35,7 @@ class User(TestCase):
summary="a summary",
bookwyrm_user=False,
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
f"nutria@{DOMAIN}",
"nutria@nutria.nutria",
"nutriaword",

View file

@ -14,21 +14,21 @@ class BookDisplayTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",
local=True,
localname="mouse",
)
self.book = models.Edition.objects.create(title="Test Book")
cls.book = models.Edition.objects.create(title="Test Book")
def test_get_book_description(self, *_):
"""grab it from the edition or the parent"""

View file

@ -13,21 +13,21 @@ class FeedPageTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",
local=True,
localname="mouse",
)
self.book = models.Edition.objects.create(title="Test Book")
cls.book = models.Edition.objects.create(title="Test Book")
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
def test_load_subclass(self, *_):

View file

@ -13,14 +13,14 @@ class InteractionTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",
@ -28,14 +28,14 @@ class InteractionTags(TestCase):
localname="mouse",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.rat",
"ratword",
remote_id="http://example.com/rat",
local=False,
)
self.book = models.Edition.objects.create(title="Test Book")
cls.book = models.Edition.objects.create(title="Test Book")
def test_get_user_liked(self, *_):
"""did a user like a status"""

View file

@ -13,14 +13,14 @@ class NotificationPageTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",

View file

@ -13,14 +13,14 @@ class RatingTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",
@ -28,7 +28,7 @@ class RatingTags(TestCase):
localname="mouse",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.rat",
"ratword",
@ -36,7 +36,7 @@ class RatingTags(TestCase):
local=False,
)
work = models.Work.objects.create(title="Work title")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Test Book",
parent_work=work,
)

View file

@ -16,14 +16,14 @@ class ShelfTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",
@ -31,14 +31,14 @@ class ShelfTags(TestCase):
localname="mouse",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.rat",
"ratword",
remote_id="http://example.com/rat",
local=False,
)
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Test Book",
parent_work=models.Work.objects.create(title="Test work"),
)

View file

@ -15,14 +15,14 @@ class StatusDisplayTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",
@ -30,14 +30,14 @@ class StatusDisplayTags(TestCase):
localname="mouse",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.rat",
"ratword",
remote_id="http://example.com/rat",
local=False,
)
self.book = models.Edition.objects.create(title="Test Book")
cls.book = models.Edition.objects.create(title="Test Book")
def test_get_mentions(self, *_):
"""list of people mentioned"""

View file

@ -15,14 +15,14 @@ class UtilitiesTags(TestCase):
"""lotta different things here"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create some filler objects"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user(
cls.user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.mouse",
"mouseword",
@ -30,15 +30,15 @@ class UtilitiesTags(TestCase):
localname="mouse",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.rat",
"ratword",
remote_id="http://example.com/rat",
local=False,
)
self.author = models.Author.objects.create(name="Jessica", isni="4")
self.book = models.Edition.objects.create(title="Test Book")
cls.author = models.Author.objects.create(name="Jessica", isni="4")
cls.book = models.Edition.objects.create(title="Test Book")
def test_get_uuid(self, *_):
"""uuid functionality"""

View file

@ -12,23 +12,23 @@ class ContextProcessor(TestCase):
"""pages you land on without really trying"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
local=True,
localname="mouse",
)
self.anonymous_user = AnonymousUser
self.anonymous_user.is_authenticated = False
self.site = models.SiteSettings.objects.create()
cls.anonymous_user = AnonymousUser
cls.anonymous_user.is_authenticated = False
cls.site = models.SiteSettings.objects.create()
def setUp(self):
"""other test data"""

View file

@ -12,14 +12,14 @@ class Emailing(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -36,24 +36,24 @@ class Signature(TestCase):
"""signature test"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""create users and test data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.mouse = models.User.objects.create_user(
cls.mouse = models.User.objects.create_user(
f"mouse@{DOMAIN}",
"mouse@example.com",
"",
local=True,
localname="mouse",
)
self.rat = models.User.objects.create_user(
cls.rat = models.User.objects.create_user(
f"rat@{DOMAIN}", "rat@example.com", "", local=True, localname="rat"
)
self.cat = models.User.objects.create_user(
cls.cat = models.User.objects.create_user(
f"cat@{DOMAIN}", "cat@example.com", "", local=True, localname="cat"
)
models.SiteSettings.objects.create()

View file

@ -12,14 +12,14 @@ class AnnouncementViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -16,14 +16,14 @@ class AutomodViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -33,7 +33,7 @@ class AutomodViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()
def setUp(self):

View file

@ -15,14 +15,14 @@ class CeleryStatusViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,7 +32,7 @@ class CeleryStatusViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="admin")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()
def setUp(self):

View file

@ -15,14 +15,14 @@ class DashboardViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,7 +32,7 @@ class DashboardViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()

View file

@ -15,14 +15,14 @@ class EmailBlocklistViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,7 +32,7 @@ class EmailBlocklistViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()

View file

@ -15,14 +15,14 @@ class EmailConfigViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,7 +32,7 @@ class EmailConfigViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="admin")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()
def setUp(self):

View file

@ -18,14 +18,14 @@ class FederationViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -33,7 +33,7 @@ class FederationViews(TestCase):
localname="mouse",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -45,7 +45,7 @@ class FederationViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()

View file

@ -15,14 +15,14 @@ class ImportsAdminViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,7 +32,7 @@ class ImportsAdminViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="admin")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()
def setUp(self):

View file

@ -15,14 +15,14 @@ class IPBlocklistViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,7 +32,7 @@ class IPBlocklistViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()

View file

@ -15,14 +15,14 @@ class LinkDomainViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,13 +32,13 @@ class LinkDomainViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
self.book = models.Edition.objects.create(title="hello")
cls.book = models.Edition.objects.create(title="hello")
models.FileLink.objects.create(
book=self.book,
book=cls.book,
url="https://beep.com/book/1",
added_by=self.local_user,
added_by=cls.local_user,
)
models.SiteSettings.objects.create()

View file

@ -16,21 +16,21 @@ class ReportViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
local=True,
localname="mouse",
)
self.rat = models.User.objects.create_user(
cls.rat = models.User.objects.create_user(
"rat@local.com",
"rat@mouse.mouse",
"password",
@ -40,7 +40,7 @@ class ReportViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()
def setUp(self):

View file

@ -15,14 +15,14 @@ class SiteSettingsViews(TestCase):
"""Edit site settings"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -32,9 +32,9 @@ class SiteSettingsViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="admin")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
self.site = models.SiteSettings.objects.create()
cls.site = models.SiteSettings.objects.create()
def setUp(self):
"""individual test setup"""

View file

@ -16,21 +16,21 @@ class AdminThemesViews(TestCase):
"""Edit site settings"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
local=True,
localname="mouse",
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"rat@local.com",
"rat@rat.rat",
"password",
@ -40,9 +40,9 @@ class AdminThemesViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="admin")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
self.site = models.SiteSettings.objects.create()
cls.site = models.SiteSettings.objects.create()
def setUp(self):
"""individual test setup"""

View file

@ -16,14 +16,14 @@ class UserAdminViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -33,7 +33,7 @@ class UserAdminViews(TestCase):
initdb.init_groups()
initdb.init_permissions()
group = Group.objects.get(name="moderator")
self.local_user.groups.set([group])
cls.local_user.groups.set([group])
models.SiteSettings.objects.create()
def setUp(self):

View file

@ -24,14 +24,14 @@ class BookViews(TestCase):
"""books books books"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -39,19 +39,19 @@ class BookViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.group = Group.objects.create(name="editor")
self.group.permissions.add(
cls.group = Group.objects.create(name="editor")
cls.group.permissions.add(
Permission.objects.create(
name="edit_book",
codename="edit_book",
content_type=ContentType.objects.get_for_model(models.User),
).id
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
models.SiteSettings.objects.create()

View file

@ -20,14 +20,14 @@ class EditBookViews(TestCase):
"""books books books"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -35,19 +35,19 @@ class EditBookViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.group = Group.objects.create(name="editor")
self.group.permissions.add(
cls.group = Group.objects.create(name="editor")
cls.group.permissions.add(
Permission.objects.create(
name="edit_book",
codename="edit_book",
content_type=ContentType.objects.get_for_model(models.User),
).id
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
models.SiteSettings.objects.create()

View file

@ -14,14 +14,14 @@ class BookViews(TestCase):
"""books books books"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -29,11 +29,11 @@ class BookViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
physical_format="paperback",
)

View file

@ -16,13 +16,13 @@ class LinkViews(TestCase):
"""books books books"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -38,13 +38,13 @@ class LinkViews(TestCase):
content_type=ContentType.objects.get_for_model(models.User),
).id
)
self.local_user.groups.add(group)
cls.local_user.groups.add(group)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
models.SiteSettings.objects.create()

View file

@ -17,14 +17,14 @@ class ImportViews(TestCase):
"""goodreads import views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -12,14 +12,14 @@ class ImportManualReviewViews(TestCase):
"""goodreads import views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -27,10 +27,10 @@ class ImportManualReviewViews(TestCase):
localname="mouse",
)
models.SiteSettings.objects.create()
self.job = models.ImportJob.objects.create(user=self.local_user, mappings={})
cls.job = models.ImportJob.objects.create(user=cls.local_user, mappings={})
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,

View file

@ -13,14 +13,14 @@ class ImportTroubleshootViews(TestCase):
"""goodreads import views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -29,7 +29,7 @@ class Inbox(TestCase):
}
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
@ -46,7 +46,7 @@ class Inbox(TestCase):
local_user.remote_id = "https://example.com/user/mouse"
local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -12,7 +12,7 @@ class InboxAdd(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
@ -29,7 +29,7 @@ class InboxAdd(TestCase):
local_user.remote_id = "https://example.com/user/mouse"
local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -40,7 +40,7 @@ class InboxAdd(TestCase):
)
work = models.Work.objects.create(title="work title")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Test",
remote_id="https://example.com/book/37292",
parent_work=work,

View file

@ -12,24 +12,24 @@ class InboxActivities(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -43,8 +43,8 @@ class InboxActivities(TestCase):
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
patch("bookwyrm.activitystreams.add_status_task.delay"),
):
self.status = models.Status.objects.create(
user=self.local_user,
cls.status = models.Status.objects.create(
user=cls.local_user,
content="Test status",
remote_id="https://example.com/status/1",
)

View file

@ -11,24 +11,24 @@ class InboxBlock(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -74,24 +74,24 @@ class InboxCreate(TestCase):
"""readthrough tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -12,24 +12,24 @@ class InboxActivities(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -39,8 +39,8 @@ class InboxActivities(TestCase):
outbox="https://example.com/users/rat/outbox",
)
with patch("bookwyrm.activitystreams.add_status_task.delay"):
self.status = models.Status.objects.create(
user=self.remote_user,
cls.status = models.Status.objects.create(
user=cls.remote_user,
content="Test status",
remote_id="https://example.com/status/1",
)

View file

@ -12,24 +12,24 @@ class InboxRelationships(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -11,24 +11,24 @@ class InboxActivities(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -42,8 +42,8 @@ class InboxActivities(TestCase):
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
patch("bookwyrm.activitystreams.add_status_task.delay"),
):
self.status = models.Status.objects.create(
user=self.local_user,
cls.status = models.Status.objects.create(
user=cls.local_user,
content="Test status",
remote_id="https://example.com/status/1",
)

View file

@ -11,24 +11,24 @@ class InboxRemove(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -38,11 +38,11 @@ class InboxRemove(TestCase):
outbox="https://example.com/users/rat/outbox",
)
self.work = models.Work.objects.create(title="work title")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="work title")
cls.book = models.Edition.objects.create(
title="Test",
remote_id="https://bookwyrm.social/book/37292",
parent_work=self.work,
parent_work=cls.work,
)
models.SiteSettings.objects.create()

View file

@ -13,24 +13,24 @@ class InboxUpdate(TestCase):
"""inbox tests"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""basic user and book data"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
"mouseword",
local=True,
localname="mouse",
)
self.local_user.remote_id = "https://example.com/user/mouse"
self.local_user.save(broadcast=False, update_fields=["remote_id"])
cls.local_user.remote_id = "https://example.com/user/mouse"
cls.local_user.save(broadcast=False, update_fields=["remote_id"])
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -15,14 +15,14 @@ class InviteViews(TestCase):
"""every response to a get request, html or json"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -15,14 +15,14 @@ class LandingViews(TestCase):
"""pages you land on without really trying"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -18,14 +18,14 @@ class LoginViews(TestCase):
"""login and password management"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@your.domain.here",
"mouse@mouse.com",
"password",
@ -33,14 +33,14 @@ class LoginViews(TestCase):
localname="mouse",
two_factor_auth=False,
)
self.rat = models.User.objects.create_user(
cls.rat = models.User.objects.create_user(
"rat@your.domain.here",
"rat@rat.com",
"password",
local=True,
localname="rat",
)
self.badger = models.User.objects.create_user(
cls.badger = models.User.objects.create_user(
"badger@your.domain.here",
"badger@badger.com",
"password",

View file

@ -17,14 +17,14 @@ class PasswordViews(TestCase):
"""view user and edit profile"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"password",

View file

@ -21,21 +21,21 @@ class RegisterViews(TestCase):
"""login and password management"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@your.domain.here",
"mouse@mouse.com",
"password",
local=True,
localname="mouse",
)
self.settings = models.SiteSettings.objects.create(
cls.settings = models.SiteSettings.objects.create(
id=1, require_confirm_email=False, allow_registration=True
)

View file

@ -16,14 +16,14 @@ class ListViews(TestCase):
"""list view"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -32,7 +32,7 @@ class ListViews(TestCase):
remote_id="https://example.com/users/mouse",
)
work = models.Work.objects.create(title="Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,
@ -42,9 +42,7 @@ class ListViews(TestCase):
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create(
name="Test List", user=self.local_user
)
cls.list = models.List.objects.create(name="Test List", user=cls.local_user)
models.SiteSettings.objects.create()

View file

@ -16,14 +16,14 @@ class ListViews(TestCase):
"""list view"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -32,7 +32,7 @@ class ListViews(TestCase):
remote_id="https://example.com/users/mouse",
)
work = models.Work.objects.create(title="Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,
@ -42,9 +42,7 @@ class ListViews(TestCase):
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create(
name="Test List", user=self.local_user
)
cls.list = models.List.objects.create(name="Test List", user=cls.local_user)
models.SiteSettings.objects.create()

View file

@ -19,14 +19,14 @@ class ListViews(TestCase):
"""list view"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -34,7 +34,7 @@ class ListViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.rat = models.User.objects.create_user(
cls.rat = models.User.objects.create_user(
"rat@local.com",
"rat@rat.com",
"ratword",
@ -43,25 +43,25 @@ class ListViews(TestCase):
remote_id="https://example.com/users/rat",
)
work = models.Work.objects.create(title="Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,
)
work_two = models.Work.objects.create(title="Labori")
self.book_two = models.Edition.objects.create(
cls.book_two = models.Edition.objects.create(
title="Example Edition 2",
remote_id="https://example.com/book/2",
parent_work=work_two,
)
work_three = models.Work.objects.create(title="Trabajar")
self.book_three = models.Edition.objects.create(
cls.book_three = models.Edition.objects.create(
title="Example Edition 3",
remote_id="https://example.com/book/3",
parent_work=work_three,
)
work_four = models.Work.objects.create(title="Travailler")
self.book_four = models.Edition.objects.create(
cls.book_four = models.Edition.objects.create(
title="Example Edition 4",
remote_id="https://example.com/book/4",
parent_work=work_four,
@ -71,9 +71,7 @@ class ListViews(TestCase):
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create(
name="Test List", user=self.local_user
)
cls.list = models.List.objects.create(name="Test List", user=cls.local_user)
models.SiteSettings.objects.create()

View file

@ -13,14 +13,14 @@ class ListItemViews(TestCase):
"""list view"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -29,7 +29,7 @@ class ListItemViews(TestCase):
remote_id="https://example.com/users/mouse",
)
work = models.Work.objects.create(title="Work")
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,
@ -38,9 +38,7 @@ class ListItemViews(TestCase):
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create(
name="Test List", user=self.local_user
)
cls.list = models.List.objects.create(name="Test List", user=cls.local_user)
models.SiteSettings.objects.create()

View file

@ -16,14 +16,14 @@ class ListViews(TestCase):
"""lists of lists"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -31,7 +31,7 @@ class ListViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"rat@local.com", "rat@rat.com", "ratword", local=True, localname="rat"
)

View file

@ -14,14 +14,14 @@ class BlockViews(TestCase):
"""view user and edit profile"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
@ -29,7 +29,7 @@ class BlockViews(TestCase):
localname="mouse",
)
with patch("bookwyrm.models.user.set_remote_server.delay"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",

View file

@ -13,14 +13,14 @@ class ChangePasswordViews(TestCase):
"""view user and edit profile"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"password",

View file

@ -17,21 +17,21 @@ class DeleteUserViews(TestCase):
"""view user and edit profile"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@your.domain.here",
"mouse@mouse.mouse",
"password",
local=True,
localname="mouse",
)
self.rat = models.User.objects.create_user(
cls.rat = models.User.objects.create_user(
"rat@your.domain.here",
"rat@rat.rat",
"password",
@ -39,7 +39,7 @@ class DeleteUserViews(TestCase):
localname="rat",
)
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="test", parent_work=models.Work.objects.create(title="test work")
)
with (
@ -47,9 +47,9 @@ class DeleteUserViews(TestCase):
patch("bookwyrm.activitystreams.add_book_statuses_task.delay"),
):
models.ShelfBook.objects.create(
book=self.book,
user=self.local_user,
shelf=self.local_user.shelf_set.first(),
book=cls.book,
user=cls.local_user,
shelf=cls.local_user.shelf_set.first(),
)
models.SiteSettings.objects.create()

View file

@ -19,25 +19,25 @@ class EditUserViews(TestCase):
"""view user and edit profile"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
local=True,
localname="mouse",
)
self.rat = models.User.objects.create_user(
cls.rat = models.User.objects.create_user(
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
)
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
title="test", parent_work=models.Work.objects.create(title="test work")
)
with (
@ -45,9 +45,9 @@ class EditUserViews(TestCase):
patch("bookwyrm.activitystreams.add_book_statuses_task.delay"),
):
models.ShelfBook.objects.create(
book=self.book,
user=self.local_user,
shelf=self.local_user.shelf_set.first(),
book=cls.book,
user=cls.local_user,
shelf=cls.local_user.shelf_set.first(),
)
models.SiteSettings.objects.create()

View file

@ -18,15 +18,13 @@ class ExportViews(TestCase):
"""viewing and creating statuses"""
@classmethod
def setUpTestData(
self,
): # pylint: disable=bad-classmethod-argument, disable=invalid-name
def setUpTestData(cls): # pylint: disable=invalid-name
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -34,11 +32,11 @@ class ExportViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Test Book",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
isbn_13="9781234567890",
bnf_id="beep",
)

View file

@ -18,14 +18,14 @@ class TwoFactorViews(TestCase):
"""Two Factor Authentication management"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@your.domain.here",
"mouse@mouse.com",
"password",

View file

@ -21,14 +21,14 @@ class ShelfViews(TestCase):
"""tag views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -36,15 +36,15 @@ class ShelfViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
self.shelf = models.Shelf.objects.create(
name="Test Shelf", identifier="test-shelf", user=self.local_user
cls.shelf = models.Shelf.objects.create(
name="Test Shelf", identifier="test-shelf", user=cls.local_user
)
models.SiteSettings.objects.create()

View file

@ -19,14 +19,14 @@ class ShelfActionViews(TestCase):
"""tag views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -34,7 +34,7 @@ class ShelfActionViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"rat@local.com",
"rat@rat.com",
"ratword",
@ -42,15 +42,15 @@ class ShelfActionViews(TestCase):
localname="rat",
remote_id="https://example.com/users/rat",
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
self.shelf = models.Shelf.objects.create(
name="Test Shelf", identifier="test-shelf", user=self.local_user
cls.shelf = models.Shelf.objects.create(
name="Test Shelf", identifier="test-shelf", user=cls.local_user
)
models.SiteSettings.objects.create()

View file

@ -22,14 +22,14 @@ class AnnualSummary(TestCase):
"""views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -38,11 +38,11 @@ class AnnualSummary(TestCase):
remote_id="https://example.com/users/mouse",
summary_keys={"2020": "0123456789"},
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
pages=300,
)
models.SiteSettings.objects.create()

View file

@ -17,14 +17,14 @@ class AuthorViews(TestCase):
"""author views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -32,19 +32,19 @@ class AuthorViews(TestCase):
localname="mouse",
remote_id="https://example.com/users/mouse",
)
self.group = Group.objects.create(name="editor")
self.group.permissions.add(
cls.group = Group.objects.create(name="editor")
cls.group.permissions.add(
Permission.objects.create(
name="edit_book",
codename="edit_book",
content_type=ContentType.objects.get_for_model(models.User),
).id
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
models.SiteSettings.objects.create()

View file

@ -14,14 +14,14 @@ class DirectoryViews(TestCase):
"""tag views"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",

View file

@ -12,14 +12,14 @@ class DiscoverViews(TestCase):
"""pages you land on without really trying"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",

View file

@ -25,28 +25,28 @@ class FeedViews(TestCase):
"""activity feed, statuses, dms"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
local=True,
localname="mouse",
)
self.another_user = models.User.objects.create_user(
cls.another_user = models.User.objects.create_user(
"nutria@local.com",
"nutria@nutria.nutria",
"password",
local=True,
localname="nutria",
)
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
parent_work=models.Work.objects.create(title="hi"),
title="Example Edition",
remote_id="https://example.com/book/1",

View file

@ -18,7 +18,7 @@ class FollowViews(TestCase):
"""follows"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
models.SiteSettings.objects.create()
with (
@ -26,7 +26,7 @@ class FollowViews(TestCase):
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.com",
"mouseword",
@ -35,7 +35,7 @@ class FollowViews(TestCase):
remote_id="https://example.com/users/mouse",
)
with patch("bookwyrm.models.user.set_remote_server"):
self.remote_user = models.User.objects.create_user(
cls.remote_user = models.User.objects.create_user(
"rat",
"rat@email.com",
"ratword",
@ -44,19 +44,19 @@ class FollowViews(TestCase):
inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox",
)
self.group = Group.objects.create(name="editor")
self.group.permissions.add(
cls.group = Group.objects.create(name="editor")
cls.group.permissions.add(
Permission.objects.create(
name="edit_book",
codename="edit_book",
content_type=ContentType.objects.get_for_model(models.User),
).id
)
self.work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
cls.work = models.Work.objects.create(title="Test Work")
cls.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,
parent_work=cls.work,
)
def setUp(self):

View file

@ -13,28 +13,28 @@ class GetStartedViews(TestCase):
"""helping new users get oriented"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"mouse@local.com",
"mouse@mouse.mouse",
"password",
local=True,
localname="mouse",
)
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"rat@local.com",
"rat@rat.rat",
"password",
local=True,
localname="rat",
)
self.book = models.Edition.objects.create(
cls.book = models.Edition.objects.create(
parent_work=models.Work.objects.create(title="hi"),
title="Example Edition",
remote_id="https://example.com/book/1",

Some files were not shown because too many files have changed in this diff Show more