mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 04:51:11 +00:00
Merge branch 'main' into let-a-user-search-within-their-books
This commit is contained in:
commit
7cca199a11
151 changed files with 855 additions and 383 deletions
|
@ -171,9 +171,19 @@ class Reject(Verb):
|
||||||
type: str = "Reject"
|
type: str = "Reject"
|
||||||
|
|
||||||
def action(self, allow_external_connections=True):
|
def action(self, allow_external_connections=True):
|
||||||
"""reject a follow request"""
|
"""reject a follow or follow request"""
|
||||||
obj = self.object.to_model(save=False, allow_create=False)
|
|
||||||
|
for model_name in ["UserFollowRequest", "UserFollows", None]:
|
||||||
|
model = apps.get_model(f"bookwyrm.{model_name}") if model_name else None
|
||||||
|
if obj := self.object.to_model(
|
||||||
|
model=model,
|
||||||
|
save=False,
|
||||||
|
allow_create=False,
|
||||||
|
allow_external_connections=allow_external_connections,
|
||||||
|
):
|
||||||
|
# Reject the first model that can be built.
|
||||||
obj.reject()
|
obj.reject()
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
|
|
|
@ -153,7 +153,7 @@ def search_title_author(
|
||||||
|
|
||||||
# filter out multiple editions of the same work
|
# filter out multiple editions of the same work
|
||||||
list_results = []
|
list_results = []
|
||||||
for work_id in set(editions_of_work[:30]):
|
for work_id in editions_of_work[:30]:
|
||||||
result = (
|
result = (
|
||||||
results.filter(parent_work=work_id)
|
results.filter(parent_work=work_id)
|
||||||
.order_by("-rank", "-edition_rank")
|
.order_by("-rank", "-edition_rank")
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
""" using django model forms """
|
""" using django model forms """
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
|
from file_resubmit.widgets import ResubmitImageWidget
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from bookwyrm.models.fields import ClearableFileInputWithWarning
|
|
||||||
from .custom_form import CustomForm
|
from .custom_form import CustomForm
|
||||||
from .widgets import ArrayWidget, SelectDateWidget, Select
|
from .widgets import ArrayWidget, SelectDateWidget, Select
|
||||||
|
|
||||||
|
@ -70,9 +71,7 @@ class EditionForm(CustomForm):
|
||||||
"published_date": SelectDateWidget(
|
"published_date": SelectDateWidget(
|
||||||
attrs={"aria-describedby": "desc_published_date"}
|
attrs={"aria-describedby": "desc_published_date"}
|
||||||
),
|
),
|
||||||
"cover": ClearableFileInputWithWarning(
|
"cover": ResubmitImageWidget(attrs={"aria-describedby": "desc_cover"}),
|
||||||
attrs={"aria-describedby": "desc_cover"}
|
|
||||||
),
|
|
||||||
"physical_format": Select(
|
"physical_format": Select(
|
||||||
attrs={"aria-describedby": "desc_physical_format"}
|
attrs={"aria-describedby": "desc_physical_format"}
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
""" look at all this nice middleware! """
|
""" look at all this nice middleware! """
|
||||||
from .timezone_middleware import TimezoneMiddleware
|
from .timezone_middleware import TimezoneMiddleware
|
||||||
from .ip_middleware import IPBlocklistMiddleware
|
from .ip_middleware import IPBlocklistMiddleware
|
||||||
|
from .file_too_big import FileTooBig
|
||||||
|
|
30
bookwyrm/middleware/file_too_big.py
Normal file
30
bookwyrm/middleware/file_too_big.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
"""Middleware to display a custom 413 error page"""
|
||||||
|
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.core.exceptions import RequestDataTooBig
|
||||||
|
|
||||||
|
|
||||||
|
class FileTooBig:
|
||||||
|
"""Middleware to display a custom page when a
|
||||||
|
RequestDataTooBig exception is thrown"""
|
||||||
|
|
||||||
|
def __init__(self, get_response):
|
||||||
|
"""boilerplate __init__ from Django docs"""
|
||||||
|
|
||||||
|
self.get_response = get_response
|
||||||
|
|
||||||
|
def __call__(self, request):
|
||||||
|
"""If RequestDataTooBig is thrown, render the 413 error page"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
body = request.body # pylint: disable=unused-variable
|
||||||
|
|
||||||
|
except RequestDataTooBig:
|
||||||
|
|
||||||
|
rendered = render(request, "413.html")
|
||||||
|
response = HttpResponse(rendered)
|
||||||
|
return response
|
||||||
|
|
||||||
|
response = self.get_response(request)
|
||||||
|
return response
|
|
@ -602,7 +602,7 @@ def to_ordered_collection_page(
|
||||||
if activity_page.has_next():
|
if activity_page.has_next():
|
||||||
next_page = f"{remote_id}?page={activity_page.next_page_number()}"
|
next_page = f"{remote_id}?page={activity_page.next_page_number()}"
|
||||||
if activity_page.has_previous():
|
if activity_page.has_previous():
|
||||||
prev_page = f"{remote_id}?page=%d{activity_page.previous_page_number()}"
|
prev_page = f"{remote_id}?page={activity_page.previous_page_number()}"
|
||||||
return activitypub.OrderedCollectionPage(
|
return activitypub.OrderedCollectionPage(
|
||||||
id=f"{remote_id}?page={page}",
|
id=f"{remote_id}?page={page}",
|
||||||
partOf=remote_id,
|
partOf=remote_id,
|
||||||
|
|
|
@ -65,6 +65,13 @@ class UserRelationship(BookWyrmModel):
|
||||||
base_path = self.user_subject.remote_id
|
base_path = self.user_subject.remote_id
|
||||||
return f"{base_path}#follows/{self.id}"
|
return f"{base_path}#follows/{self.id}"
|
||||||
|
|
||||||
|
def get_accept_reject_id(self, status):
|
||||||
|
"""get id for sending an accept or reject of a local user"""
|
||||||
|
|
||||||
|
base_path = self.user_object.remote_id
|
||||||
|
status_id = self.id or 0
|
||||||
|
return f"{base_path}#{status}/{status_id}"
|
||||||
|
|
||||||
|
|
||||||
class UserFollows(ActivityMixin, UserRelationship):
|
class UserFollows(ActivityMixin, UserRelationship):
|
||||||
"""Following a user"""
|
"""Following a user"""
|
||||||
|
@ -105,6 +112,20 @@ class UserFollows(ActivityMixin, UserRelationship):
|
||||||
)
|
)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
def reject(self):
|
||||||
|
"""generate a Reject for this follow. This would normally happen
|
||||||
|
when a user deletes a follow they previously accepted"""
|
||||||
|
|
||||||
|
if self.user_object.local:
|
||||||
|
activity = activitypub.Reject(
|
||||||
|
id=self.get_accept_reject_id(status="rejects"),
|
||||||
|
actor=self.user_object.remote_id,
|
||||||
|
object=self.to_activity(),
|
||||||
|
).serialize()
|
||||||
|
self.broadcast(activity, self.user_object)
|
||||||
|
|
||||||
|
self.delete()
|
||||||
|
|
||||||
|
|
||||||
class UserFollowRequest(ActivitypubMixin, UserRelationship):
|
class UserFollowRequest(ActivitypubMixin, UserRelationship):
|
||||||
"""following a user requires manual or automatic confirmation"""
|
"""following a user requires manual or automatic confirmation"""
|
||||||
|
@ -148,13 +169,6 @@ class UserFollowRequest(ActivitypubMixin, UserRelationship):
|
||||||
if not manually_approves:
|
if not manually_approves:
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
def get_accept_reject_id(self, status):
|
|
||||||
"""get id for sending an accept or reject of a local user"""
|
|
||||||
|
|
||||||
base_path = self.user_object.remote_id
|
|
||||||
status_id = self.id or 0
|
|
||||||
return f"{base_path}#{status}/{status_id}"
|
|
||||||
|
|
||||||
def accept(self, broadcast_only=False):
|
def accept(self, broadcast_only=False):
|
||||||
"""turn this request into the real deal"""
|
"""turn this request into the real deal"""
|
||||||
user = self.user_object
|
user = self.user_object
|
||||||
|
|
|
@ -99,6 +99,7 @@ INSTALLED_APPS = [
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
"django.contrib.humanize",
|
"django.contrib.humanize",
|
||||||
|
"file_resubmit",
|
||||||
"sass_processor",
|
"sass_processor",
|
||||||
"bookwyrm",
|
"bookwyrm",
|
||||||
"celery",
|
"celery",
|
||||||
|
@ -119,6 +120,7 @@ MIDDLEWARE = [
|
||||||
"bookwyrm.middleware.IPBlocklistMiddleware",
|
"bookwyrm.middleware.IPBlocklistMiddleware",
|
||||||
"django.contrib.messages.middleware.MessageMiddleware",
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
|
"bookwyrm.middleware.FileTooBig",
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = "bookwyrm.urls"
|
ROOT_URLCONF = "bookwyrm.urls"
|
||||||
|
@ -242,7 +244,11 @@ if env.bool("USE_DUMMY_CACHE", False):
|
||||||
CACHES = {
|
CACHES = {
|
||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
|
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
|
||||||
}
|
},
|
||||||
|
"file_resubmit": {
|
||||||
|
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
|
||||||
|
"LOCATION": "/tmp/file_resubmit_tests/",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
CACHES = {
|
CACHES = {
|
||||||
|
@ -252,7 +258,11 @@ else:
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
"file_resubmit": {
|
||||||
|
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
|
||||||
|
"LOCATION": "/tmp/file_resubmit/",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
||||||
|
|
16
bookwyrm/templates/413.html
Normal file
16
bookwyrm/templates/413.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{% extends 'layout.html' %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block title %}{% trans "File too large" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="block">
|
||||||
|
<h1 class="title">{% trans "File too large" %}</h1>
|
||||||
|
<p class="content">{% trans "The file you are uploading is too large." %}</p>
|
||||||
|
<p class="content">
|
||||||
|
{% blocktrans %}
|
||||||
|
You you can try using a smaller file, or ask your BookWyrm server administrator to increase the <code>DATA_UPLOAD_MAX_MEMORY_SIZE</code> setting.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -19,20 +19,7 @@
|
||||||
</h1>
|
</h1>
|
||||||
</header>
|
</header>
|
||||||
{% if user.moved_to %}
|
{% if user.moved_to %}
|
||||||
<div class="container my-6">
|
{% include "snippets/moved_user_notice.html" with user=user %}
|
||||||
<div class="notification is-info has-text-centered">
|
|
||||||
<p>
|
|
||||||
{% trans "You have have moved to" %}
|
|
||||||
<a href="{{user.moved_to}}">{% id_to_username user.moved_to %}</a>
|
|
||||||
</p>
|
|
||||||
<p> {% trans "You can undo this move to restore full functionality, but some followers may have already unfollowed this account." %}</p>
|
|
||||||
<form name="remove-alias" action="{% url 'prefs-unmove' %}" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
<input type="hidden" name="remote_id" id="remote_id" value="{{user.moved_to}}">
|
|
||||||
<button type="submit" class="button is-small">{% trans "Undo move" %}</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<nav class="breadcrumb subtitle" aria-label="breadcrumbs">
|
<nav class="breadcrumb subtitle" aria-label="breadcrumbs">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% if not minimal %}
|
{% if not minimal %}
|
||||||
<div class="control">
|
<div class="control">
|
||||||
{% include 'snippets/user_options.html' with user=user class="is-small" %}
|
{% include 'snippets/user_options.html' with user=user followers_page=followers_page class="is-small" %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
12
bookwyrm/templates/snippets/moved_user_notice.html
Normal file
12
bookwyrm/templates/snippets/moved_user_notice.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{% load i18n %}
|
||||||
|
{% load utilities %}
|
||||||
|
<div class="container my-6">
|
||||||
|
<div class="notification is-info has-text-centered">
|
||||||
|
<p>
|
||||||
|
{% id_to_username user.moved_to as moved_to_name %}
|
||||||
|
{% blocktrans trimmed with user=user|username moved_to_link=user.moved_to %}
|
||||||
|
<em>{{ user }}</em> has moved to <a href="{{ moved_to_link }}">{{ moved_to_name }}</a>
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
5
bookwyrm/templates/snippets/remove_follower_button.html
Normal file
5
bookwyrm/templates/snippets/remove_follower_button.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{% load i18n %}
|
||||||
|
<form name="remove" method="post" action="/remove-follow/{{ user.id }}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button class="button is-danger is-light is-small {{ class }}" type="submit">{% trans "Remove" %}</button>
|
||||||
|
</form>
|
|
@ -20,4 +20,9 @@
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
{% include 'snippets/block_button.html' with user=user class="is-fullwidth" blocks=False %}
|
{% include 'snippets/block_button.html' with user=user class="is-fullwidth" blocks=False %}
|
||||||
</li>
|
</li>
|
||||||
|
{% if followers_page %}
|
||||||
|
<li role="menuitem">
|
||||||
|
{% include 'snippets/remove_follower_button.html' with user=user class="is-fullwidth" %}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -45,12 +45,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{% if user.moved_to %}
|
{% if user.moved_to %}
|
||||||
<div class="container my-6">
|
{% include "snippets/moved_user_notice.html" with user=user %}
|
||||||
<div class="notification is-info has-text-centered">
|
|
||||||
<p><em>{{ user.localname }}</em> {% trans "has moved to" %} <a href="{{user.moved_to}}">{% id_to_username user.moved_to %}</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if not is_self and request.user.is_authenticated %}
|
{% if not is_self and request.user.is_authenticated %}
|
||||||
{% include 'snippets/follow_button.html' with user=user %}
|
{% include 'snippets/follow_button.html' with user=user %}
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
</nav>
|
</nav>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block panel %}
|
||||||
|
{% with followers_page=True %}
|
||||||
|
{{ block.super }}
|
||||||
|
{% endwith %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block nullstate %}
|
{% block nullstate %}
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
({{ follow.username }})
|
({{ follow.username }})
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-narrow">
|
<div class="column is-narrow">
|
||||||
{% include 'snippets/follow_button.html' with user=follow %}
|
{% include 'snippets/follow_button.html' with user=follow followers_page=followers_page %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -6,7 +6,8 @@ from bookwyrm import models
|
||||||
class Author(TestCase):
|
class Author(TestCase):
|
||||||
"""serialize author tests"""
|
"""serialize author tests"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""initial data"""
|
"""initial data"""
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
|
|
|
@ -28,8 +28,8 @@ from bookwyrm import models
|
||||||
class BaseActivity(TestCase):
|
class BaseActivity(TestCase):
|
||||||
"""the super class for model-linked activitypub dataclasses"""
|
"""the super class for model-linked activitypub dataclasses"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we're probably going to re-use this so why copy/paste"""
|
"""we're probably going to re-use this so why copy/paste"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -40,6 +40,7 @@ class BaseActivity(TestCase):
|
||||||
self.user.remote_id = "http://example.com/a/b"
|
self.user.remote_id = "http://example.com/a/b"
|
||||||
self.user.save(broadcast=False, update_fields=["remote_id"])
|
self.user.save(broadcast=False, update_fields=["remote_id"])
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_user.json")
|
||||||
self.userdata = json.loads(datafile.read_bytes())
|
self.userdata = json.loads(datafile.read_bytes())
|
||||||
# don't try to load the user icon
|
# don't try to load the user icon
|
||||||
|
|
|
@ -10,8 +10,8 @@ from bookwyrm import models
|
||||||
class Note(TestCase):
|
class Note(TestCase):
|
||||||
"""the model-linked ActivityPub dataclass for Note-based types"""
|
"""the model-linked ActivityPub dataclass for Note-based types"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create a shared user"""
|
"""create a shared user"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -10,7 +10,8 @@ from bookwyrm import activitypub, models
|
||||||
class Quotation(TestCase):
|
class Quotation(TestCase):
|
||||||
"""we have hecka ways to create statuses"""
|
"""we have hecka ways to create statuses"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""model objects we'll need"""
|
"""model objects we'll need"""
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
|
@ -26,6 +27,9 @@ class Quotation(TestCase):
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""other test data"""
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_quotation.json")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/ap_quotation.json")
|
||||||
self.status_data = json.loads(datafile.read_bytes())
|
self.status_data = json.loads(datafile.read_bytes())
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ from bookwyrm import activitystreams, models
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -43,6 +44,9 @@ class Activitystreams(TestCase):
|
||||||
work = models.Work.objects.create(title="test work")
|
work = models.Work.objects.create(title="test work")
|
||||||
self.book = models.Edition.objects.create(title="test book", parent_work=work)
|
self.book = models.Edition.objects.create(title="test book", parent_work=work)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""per-test setUp"""
|
||||||
|
|
||||||
class TestStream(activitystreams.ActivityStream):
|
class TestStream(activitystreams.ActivityStream):
|
||||||
"""test stream, don't have to do anything here"""
|
"""test stream, don't have to do anything here"""
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ from bookwyrm import activitystreams, models
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm import activitystreams, models
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm import activitystreams, models
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -14,7 +14,8 @@ from bookwyrm import activitystreams, models
|
||||||
class ActivitystreamsSignals(TestCase):
|
class ActivitystreamsSignals(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -22,9 +23,6 @@ class ActivitystreamsSignals(TestCase):
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
||||||
)
|
)
|
||||||
self.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"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
"rat",
|
"rat",
|
||||||
|
@ -35,8 +33,6 @@ class ActivitystreamsSignals(TestCase):
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
work = models.Work.objects.create(title="test work")
|
|
||||||
self.book = models.Edition.objects.create(title="test book", parent_work=work)
|
|
||||||
|
|
||||||
def test_add_status_on_create_ignore(self, *_):
|
def test_add_status_on_create_ignore(self, *_):
|
||||||
"""a new statuses has entered"""
|
"""a new statuses has entered"""
|
||||||
|
|
|
@ -7,8 +7,8 @@ from bookwyrm import activitystreams, models
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,9 +12,10 @@ from bookwyrm.settings import DOMAIN
|
||||||
class AbstractConnector(TestCase):
|
class AbstractConnector(TestCase):
|
||||||
"""generic code for connecting to outside data sources"""
|
"""generic code for connecting to outside data sources"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""we need an example connector"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
self.connector_info = models.Connector.objects.create(
|
"""we need an example connector in the database"""
|
||||||
|
models.Connector.objects.create(
|
||||||
identifier="example.com",
|
identifier="example.com",
|
||||||
connector_file="openlibrary",
|
connector_file="openlibrary",
|
||||||
base_url="https://example.com",
|
base_url="https://example.com",
|
||||||
|
@ -22,19 +23,27 @@ class AbstractConnector(TestCase):
|
||||||
covers_url="https://example.com/covers",
|
covers_url="https://example.com/covers",
|
||||||
search_url="https://example.com/search?q=",
|
search_url="https://example.com/search?q=",
|
||||||
)
|
)
|
||||||
|
self.book = models.Edition.objects.create(
|
||||||
|
title="Test Book",
|
||||||
|
remote_id="https://example.com/book/1234",
|
||||||
|
openlibrary_key="OL1234M",
|
||||||
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""test data"""
|
||||||
work_data = {
|
work_data = {
|
||||||
"id": "abc1",
|
"id": "abc1",
|
||||||
"title": "Test work",
|
"title": "Test work",
|
||||||
"type": "work",
|
"type": "work",
|
||||||
"openlibraryKey": "OL1234W",
|
"openlibraryKey": "OL1234W",
|
||||||
}
|
}
|
||||||
self.work_data = work_data
|
|
||||||
edition_data = {
|
edition_data = {
|
||||||
"id": "abc2",
|
"id": "abc2",
|
||||||
"title": "Test edition",
|
"title": "Test edition",
|
||||||
"type": "edition",
|
"type": "edition",
|
||||||
"openlibraryKey": "OL1234M",
|
"openlibraryKey": "OL1234M",
|
||||||
}
|
}
|
||||||
|
self.work_data = work_data
|
||||||
self.edition_data = edition_data
|
self.edition_data = edition_data
|
||||||
|
|
||||||
class TestConnector(abstract_connector.AbstractConnector):
|
class TestConnector(abstract_connector.AbstractConnector):
|
||||||
|
@ -70,12 +79,6 @@ class AbstractConnector(TestCase):
|
||||||
Mapping("openlibraryKey"),
|
Mapping("openlibraryKey"),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.book = models.Edition.objects.create(
|
|
||||||
title="Test Book",
|
|
||||||
remote_id="https://example.com/book/1234",
|
|
||||||
openlibrary_key="OL1234M",
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_abstract_connector_init(self):
|
def test_abstract_connector_init(self):
|
||||||
"""barebones connector for search with defaults"""
|
"""barebones connector for search with defaults"""
|
||||||
self.assertIsInstance(self.connector.book_mappings, list)
|
self.assertIsInstance(self.connector.book_mappings, list)
|
||||||
|
|
|
@ -9,8 +9,9 @@ from bookwyrm.connectors.abstract_connector import Mapping
|
||||||
class AbstractConnector(TestCase):
|
class AbstractConnector(TestCase):
|
||||||
"""generic code for connecting to outside data sources"""
|
"""generic code for connecting to outside data sources"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""we need an example connector"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""we need an example connector in the database"""
|
||||||
self.connector_info = models.Connector.objects.create(
|
self.connector_info = models.Connector.objects.create(
|
||||||
identifier="example.com",
|
identifier="example.com",
|
||||||
connector_file="openlibrary",
|
connector_file="openlibrary",
|
||||||
|
@ -21,6 +22,9 @@ class AbstractConnector(TestCase):
|
||||||
isbn_search_url="https://example.com/isbn?q=",
|
isbn_search_url="https://example.com/isbn?q=",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""instantiate example connector"""
|
||||||
|
|
||||||
class TestConnector(abstract_connector.AbstractMinimalConnector):
|
class TestConnector(abstract_connector.AbstractMinimalConnector):
|
||||||
"""nothing added here"""
|
"""nothing added here"""
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,9 @@ from bookwyrm.connectors.bookwyrm_connector import Connector
|
||||||
class BookWyrmConnector(TestCase):
|
class BookWyrmConnector(TestCase):
|
||||||
"""this connector doesn't do much, just search"""
|
"""this connector doesn't do much, just search"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""create the connector"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""create bookwrym_connector in the database"""
|
||||||
models.Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="example.com",
|
identifier="example.com",
|
||||||
connector_file="bookwyrm_connector",
|
connector_file="bookwyrm_connector",
|
||||||
|
@ -21,6 +22,9 @@ class BookWyrmConnector(TestCase):
|
||||||
covers_url="https://example.com/images/covers",
|
covers_url="https://example.com/images/covers",
|
||||||
search_url="https://example.com/search?q=",
|
search_url="https://example.com/search?q=",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""test data"""
|
||||||
self.connector = Connector("example.com")
|
self.connector = Connector("example.com")
|
||||||
|
|
||||||
def test_get_or_create_book_existing(self):
|
def test_get_or_create_book_existing(self):
|
||||||
|
|
|
@ -10,7 +10,8 @@ from bookwyrm.connectors.bookwyrm_connector import Connector as BookWyrmConnecto
|
||||||
class ConnectorManager(TestCase):
|
class ConnectorManager(TestCase):
|
||||||
"""interface between the app and various connectors"""
|
"""interface between the app and various connectors"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we'll need some books and a connector info entry"""
|
"""we'll need some books and a connector info entry"""
|
||||||
self.work = models.Work.objects.create(title="Example Work")
|
self.work = models.Work.objects.create(title="Example Work")
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,9 @@ from bookwyrm.connectors.connector_manager import ConnectorException
|
||||||
class Inventaire(TestCase):
|
class Inventaire(TestCase):
|
||||||
"""test loading data from inventaire.io"""
|
"""test loading data from inventaire.io"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""creates the connector we'll use"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""creates the connector in the database"""
|
||||||
models.Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="inventaire.io",
|
identifier="inventaire.io",
|
||||||
name="Inventaire",
|
name="Inventaire",
|
||||||
|
@ -26,6 +27,9 @@ class Inventaire(TestCase):
|
||||||
search_url="https://inventaire.io/search?q=",
|
search_url="https://inventaire.io/search?q=",
|
||||||
isbn_search_url="https://inventaire.io/isbn",
|
isbn_search_url="https://inventaire.io/isbn",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""connector instance"""
|
||||||
self.connector = Connector("inventaire.io")
|
self.connector = Connector("inventaire.io")
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
|
|
|
@ -18,8 +18,9 @@ from bookwyrm.connectors.connector_manager import ConnectorException
|
||||||
class Openlibrary(TestCase):
|
class Openlibrary(TestCase):
|
||||||
"""test loading data from openlibrary.org"""
|
"""test loading data from openlibrary.org"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""creates the connector we'll use"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""creates the connector in the database"""
|
||||||
models.Connector.objects.create(
|
models.Connector.objects.create(
|
||||||
identifier="openlibrary.org",
|
identifier="openlibrary.org",
|
||||||
name="OpenLibrary",
|
name="OpenLibrary",
|
||||||
|
@ -30,6 +31,9 @@ class Openlibrary(TestCase):
|
||||||
search_url="https://openlibrary.org/search?q=",
|
search_url="https://openlibrary.org/search?q=",
|
||||||
isbn_search_url="https://openlibrary.org/isbn",
|
isbn_search_url="https://openlibrary.org/isbn",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""connector instance and other test data"""
|
||||||
self.connector = Connector("openlibrary.org")
|
self.connector = Connector("openlibrary.org")
|
||||||
|
|
||||||
work_file = pathlib.Path(__file__).parent.joinpath("../data/ol_work.json")
|
work_file = pathlib.Path(__file__).parent.joinpath("../data/ol_work.json")
|
||||||
|
|
|
@ -16,12 +16,15 @@ from bookwyrm.models.import_job import handle_imported_book
|
||||||
class CalibreImport(TestCase):
|
class CalibreImport(TestCase):
|
||||||
"""importing from Calibre csv"""
|
"""importing from Calibre csv"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
self.importer = CalibreImporter()
|
self.importer = CalibreImporter()
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/calibre.csv")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/calibre.csv")
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""populate database"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -23,12 +23,15 @@ def make_date(*args):
|
||||||
class GoodreadsImport(TestCase):
|
class GoodreadsImport(TestCase):
|
||||||
"""importing from goodreads csv"""
|
"""importing from goodreads csv"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
self.importer = GoodreadsImporter()
|
self.importer = GoodreadsImporter()
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/goodreads.csv")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/goodreads.csv")
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""populate database"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -26,13 +26,15 @@ def make_date(*args):
|
||||||
class GenericImporter(TestCase):
|
class GenericImporter(TestCase):
|
||||||
"""importing from csv"""
|
"""importing from csv"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
|
|
||||||
self.importer = Importer()
|
self.importer = Importer()
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/generic.csv")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/generic.csv")
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""populate database"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -23,7 +23,6 @@ def make_date(*args):
|
||||||
class LibrarythingImport(TestCase):
|
class LibrarythingImport(TestCase):
|
||||||
"""importing from librarything tsv"""
|
"""importing from librarything tsv"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""use a test tsv"""
|
"""use a test tsv"""
|
||||||
self.importer = LibrarythingImporter()
|
self.importer = LibrarythingImporter()
|
||||||
|
@ -31,6 +30,10 @@ class LibrarythingImport(TestCase):
|
||||||
|
|
||||||
# Librarything generates latin encoded exports...
|
# Librarything generates latin encoded exports...
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""populate database"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -23,12 +23,15 @@ def make_date(*args):
|
||||||
class OpenLibraryImport(TestCase):
|
class OpenLibraryImport(TestCase):
|
||||||
"""importing from openlibrary csv"""
|
"""importing from openlibrary csv"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
self.importer = OpenLibraryImporter()
|
self.importer = OpenLibraryImporter()
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/openlibrary.csv")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/openlibrary.csv")
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""populate database"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -23,12 +23,15 @@ def make_date(*args):
|
||||||
class StorygraphImport(TestCase):
|
class StorygraphImport(TestCase):
|
||||||
"""importing from storygraph csv"""
|
"""importing from storygraph csv"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""use a test csv"""
|
"""use a test csv"""
|
||||||
self.importer = StorygraphImporter()
|
self.importer = StorygraphImporter()
|
||||||
datafile = pathlib.Path(__file__).parent.joinpath("../data/storygraph.csv")
|
datafile = pathlib.Path(__file__).parent.joinpath("../data/storygraph.csv")
|
||||||
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
self.csv = open(datafile, "r", encoding=self.importer.encoding)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""populate database"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -8,8 +8,9 @@ from bookwyrm import lists_stream, models
|
||||||
class ListsStreamSignals(TestCase):
|
class ListsStreamSignals(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""use a test csv"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""database setup"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -15,8 +15,9 @@ from bookwyrm import lists_stream, models
|
||||||
class ListsStream(TestCase):
|
class ListsStream(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""use a test csv"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""database setup"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -10,8 +10,9 @@ from bookwyrm import lists_stream, models
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
"""use a test csv"""
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""database setup"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm.management.commands.populate_lists_streams import populate_lists_s
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need some stuff"""
|
"""we need some stuff"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -10,7 +10,8 @@ from bookwyrm.management.commands.populate_streams import populate_streams
|
||||||
class Activitystreams(TestCase):
|
class Activitystreams(TestCase):
|
||||||
"""using redis to build activity streams"""
|
"""using redis to build activity streams"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need some stuff"""
|
"""we need some stuff"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -26,7 +26,8 @@ from bookwyrm.settings import PAGE_LENGTH
|
||||||
class ActivitypubMixins(TestCase):
|
class ActivitypubMixins(TestCase):
|
||||||
"""functionality shared across models"""
|
"""functionality shared across models"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""shared data"""
|
"""shared data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -47,6 +48,8 @@ class ActivitypubMixins(TestCase):
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""test data"""
|
||||||
self.object_mock = {
|
self.object_mock = {
|
||||||
"to": "to field",
|
"to": "to field",
|
||||||
"cc": "cc field",
|
"cc": "cc field",
|
||||||
|
@ -391,11 +394,13 @@ class ActivitypubMixins(TestCase):
|
||||||
def test_to_ordered_collection_page(self, *_):
|
def test_to_ordered_collection_page(self, *_):
|
||||||
"""make sure the paged results of an ordered collection work"""
|
"""make sure the paged results of an ordered collection work"""
|
||||||
self.assertEqual(PAGE_LENGTH, 15)
|
self.assertEqual(PAGE_LENGTH, 15)
|
||||||
for number in range(0, 2 * PAGE_LENGTH):
|
models.Status.objects.bulk_create(
|
||||||
models.Status.objects.create(
|
models.Status(
|
||||||
user=self.local_user,
|
user=self.local_user,
|
||||||
content=f"test status {number}",
|
content=f"test status {number}",
|
||||||
)
|
)
|
||||||
|
for number in range(2 * PAGE_LENGTH)
|
||||||
|
)
|
||||||
page_1 = to_ordered_collection_page(
|
page_1 = to_ordered_collection_page(
|
||||||
models.Status.objects.all(), "http://fish.com/", page=1
|
models.Status.objects.all(), "http://fish.com/", page=1
|
||||||
)
|
)
|
||||||
|
@ -416,13 +421,13 @@ class ActivitypubMixins(TestCase):
|
||||||
def test_to_ordered_collection(self, *_):
|
def test_to_ordered_collection(self, *_):
|
||||||
"""convert a queryset into an ordered collection object"""
|
"""convert a queryset into an ordered collection object"""
|
||||||
self.assertEqual(PAGE_LENGTH, 15)
|
self.assertEqual(PAGE_LENGTH, 15)
|
||||||
|
models.Status.objects.bulk_create(
|
||||||
for number in range(0, 2 * PAGE_LENGTH):
|
models.Status(
|
||||||
models.Status.objects.create(
|
|
||||||
user=self.local_user,
|
user=self.local_user,
|
||||||
content=f"test status {number}",
|
content=f"test status {number}",
|
||||||
)
|
)
|
||||||
|
for number in range(2 * PAGE_LENGTH)
|
||||||
|
)
|
||||||
MockSelf = namedtuple("Self", ("remote_id"))
|
MockSelf = namedtuple("Self", ("remote_id"))
|
||||||
mock_self = MockSelf("")
|
mock_self = MockSelf("")
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,9 @@ from bookwyrm.models.antispam import automod_task
|
||||||
class AutomodModel(TestCase):
|
class AutomodModel(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -30,6 +29,9 @@ class AutomodModel(TestCase):
|
||||||
is_superuser=True,
|
is_superuser=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_automod_task_no_rules(self, *_):
|
def test_automod_task_no_rules(self, *_):
|
||||||
"""nothing to see here"""
|
"""nothing to see here"""
|
||||||
self.assertFalse(models.Report.objects.exists())
|
self.assertFalse(models.Report.objects.exists())
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm.settings import DOMAIN
|
||||||
class BaseModel(TestCase):
|
class BaseModel(TestCase):
|
||||||
"""functionality shared across models"""
|
"""functionality shared across models"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""shared data"""
|
"""shared data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -31,6 +32,7 @@ class BaseModel(TestCase):
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
class BookWyrmTestModel(base_model.BookWyrmModel):
|
class BookWyrmTestModel(base_model.BookWyrmModel):
|
||||||
"""just making it not abstract"""
|
"""just making it not abstract"""
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ from bookwyrm.settings import ENABLE_THUMBNAIL_GENERATION
|
||||||
class Book(TestCase):
|
class Book(TestCase):
|
||||||
"""not too much going on in the books model but here we are"""
|
"""not too much going on in the books model but here we are"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we'll need some books"""
|
"""we'll need some books"""
|
||||||
self.work = models.Work.objects.create(
|
self.work = models.Work.objects.create(
|
||||||
title="Example Work", remote_id="https://example.com/book/1"
|
title="Example Work", remote_id="https://example.com/book/1"
|
||||||
|
|
|
@ -9,7 +9,8 @@ from bookwyrm import models
|
||||||
class Group(TestCase):
|
class Group(TestCase):
|
||||||
"""some activitypub oddness ahead"""
|
"""some activitypub oddness ahead"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""Set up for tests"""
|
"""Set up for tests"""
|
||||||
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
|
|
|
@ -16,7 +16,8 @@ from bookwyrm.connectors import connector_manager
|
||||||
class ImportJob(TestCase):
|
class ImportJob(TestCase):
|
||||||
"""this is a fancy one!!!"""
|
"""this is a fancy one!!!"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""data is from a goodreads export of The Raven Tower"""
|
"""data is from a goodreads export of The Raven Tower"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -24,6 +25,8 @@ class ImportJob(TestCase):
|
||||||
self.local_user = models.User.objects.create_user(
|
self.local_user = models.User.objects.create_user(
|
||||||
"mouse", "mouse@mouse.mouse", "password", local=True
|
"mouse", "mouse@mouse.mouse", "password", local=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
self.job = models.ImportJob.objects.create(user=self.local_user, mappings={})
|
self.job = models.ImportJob.objects.create(user=self.local_user, mappings={})
|
||||||
|
|
||||||
def test_isbn(self):
|
def test_isbn(self):
|
||||||
|
|
|
@ -9,17 +9,6 @@ from bookwyrm import models
|
||||||
class Link(TestCase):
|
class Link(TestCase):
|
||||||
"""some activitypub oddness ahead"""
|
"""some activitypub oddness ahead"""
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
"""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(
|
|
||||||
"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)
|
|
||||||
|
|
||||||
def test_create_domain(self, _):
|
def test_create_domain(self, _):
|
||||||
"""generated default name"""
|
"""generated default name"""
|
||||||
domain = models.LinkDomain.objects.create(domain="beep.com")
|
domain = models.LinkDomain.objects.create(domain="beep.com")
|
||||||
|
|
|
@ -11,7 +11,8 @@ from bookwyrm import models, settings
|
||||||
class List(TestCase):
|
class List(TestCase):
|
||||||
"""some activitypub oddness ahead"""
|
"""some activitypub oddness ahead"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""look, a list"""
|
"""look, a list"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -7,7 +7,8 @@ from bookwyrm import models
|
||||||
class Notification(TestCase):
|
class Notification(TestCase):
|
||||||
"""let people know things"""
|
"""let people know things"""
|
||||||
|
|
||||||
def setUp(self): # pylint: disable=invalid-name
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""useful things for creating a notification"""
|
"""useful things for creating a notification"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -197,7 +198,8 @@ class Notification(TestCase):
|
||||||
class NotifyInviteRequest(TestCase):
|
class NotifyInviteRequest(TestCase):
|
||||||
"""let admins know of invite requests"""
|
"""let admins know of invite requests"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""ensure there is one admin"""
|
"""ensure there is one admin"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -11,7 +11,8 @@ from bookwyrm import models
|
||||||
class ReadThrough(TestCase):
|
class ReadThrough(TestCase):
|
||||||
"""some activitypub oddness ahead"""
|
"""some activitypub oddness ahead"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""look, a shelf"""
|
"""look, a shelf"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -14,7 +14,8 @@ from bookwyrm import models
|
||||||
class Relationship(TestCase):
|
class Relationship(TestCase):
|
||||||
"""following, blocking, stuff like that"""
|
"""following, blocking, stuff like that"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need some users for this"""
|
"""we need some users for this"""
|
||||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
self.remote_user = models.User.objects.create_user(
|
||||||
|
|
|
@ -15,7 +15,8 @@ from bookwyrm import models, settings
|
||||||
class Shelf(TestCase):
|
class Shelf(TestCase):
|
||||||
"""some activitypub oddness ahead"""
|
"""some activitypub oddness ahead"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""look, a shelf"""
|
"""look, a shelf"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm import models, settings
|
||||||
class SiteModels(TestCase):
|
class SiteModels(TestCase):
|
||||||
"""tests for site models"""
|
"""tests for site models"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -24,8 +24,8 @@ from bookwyrm import activitypub, models, settings
|
||||||
class Status(TestCase):
|
class Status(TestCase):
|
||||||
"""lotta types of statuses"""
|
"""lotta types of statuses"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""useful things for creating a status"""
|
"""useful things for creating a status"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -45,6 +45,10 @@ class Status(TestCase):
|
||||||
)
|
)
|
||||||
self.book = models.Edition.objects.create(title="Test Edition")
|
self.book = models.Edition.objects.create(title="Test Edition")
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.anonymous_user = AnonymousUser
|
||||||
|
self.anonymous_user.is_authenticated = False
|
||||||
image_file = pathlib.Path(__file__).parent.joinpath(
|
image_file = pathlib.Path(__file__).parent.joinpath(
|
||||||
"../../static/images/default_avi.jpg"
|
"../../static/images/default_avi.jpg"
|
||||||
)
|
)
|
||||||
|
@ -54,9 +58,6 @@ class Status(TestCase):
|
||||||
image.save(output, format=image.format)
|
image.save(output, format=image.format)
|
||||||
self.book.cover.save("test.jpg", ContentFile(output.getvalue()))
|
self.book.cover.save("test.jpg", ContentFile(output.getvalue()))
|
||||||
|
|
||||||
self.anonymous_user = AnonymousUser
|
|
||||||
self.anonymous_user.is_authenticated = False
|
|
||||||
|
|
||||||
def test_status_generated_fields(self, *_):
|
def test_status_generated_fields(self, *_):
|
||||||
"""setting remote id"""
|
"""setting remote id"""
|
||||||
status = models.Status.objects.create(content="bleh", user=self.local_user)
|
status = models.Status.objects.create(content="bleh", user=self.local_user)
|
||||||
|
|
|
@ -18,8 +18,8 @@ class User(TestCase):
|
||||||
|
|
||||||
protocol = "https://" if USE_HTTPS else "http://"
|
protocol = "https://" if USE_HTTPS else "http://"
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
|
|
@ -13,7 +13,8 @@ from bookwyrm.templatetags import book_display_tags
|
||||||
class BookDisplayTags(TestCase):
|
class BookDisplayTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm.templatetags import feed_page_tags
|
||||||
class FeedPageTags(TestCase):
|
class FeedPageTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm.templatetags import interaction
|
||||||
class InteractionTags(TestCase):
|
class InteractionTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm.templatetags import notification_page_tags
|
||||||
class NotificationPageTags(TestCase):
|
class NotificationPageTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -12,7 +12,8 @@ from bookwyrm.templatetags import rating_tags
|
||||||
class RatingTags(TestCase):
|
class RatingTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -15,9 +15,9 @@ from bookwyrm.templatetags import shelf_tags
|
||||||
class ShelfTags(TestCase):
|
class ShelfTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -41,6 +41,10 @@ class ShelfTags(TestCase):
|
||||||
parent_work=models.Work.objects.create(title="Test work"),
|
parent_work=models.Work.objects.create(title="Test work"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""test data"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_get_is_book_on_shelf(self, *_):
|
def test_get_is_book_on_shelf(self, *_):
|
||||||
"""check if a book is on a shelf"""
|
"""check if a book is on a shelf"""
|
||||||
shelf = self.local_user.shelf_set.first()
|
shelf = self.local_user.shelf_set.first()
|
||||||
|
|
|
@ -14,7 +14,8 @@ from bookwyrm.templatetags import status_display
|
||||||
class StatusDisplayTags(TestCase):
|
class StatusDisplayTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -14,8 +14,8 @@ from bookwyrm.templatetags import utilities
|
||||||
class UtilitiesTags(TestCase):
|
class UtilitiesTags(TestCase):
|
||||||
"""lotta different things here"""
|
"""lotta different things here"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create some filler objects"""
|
"""create some filler objects"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -10,7 +10,8 @@ from bookwyrm.connectors.abstract_connector import AbstractMinimalConnector
|
||||||
class BookSearch(TestCase):
|
class BookSearch(TestCase):
|
||||||
"""look for some books"""
|
"""look for some books"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.work = models.Work.objects.create(title="Example Work")
|
self.work = models.Work.objects.create(title="Example Work")
|
||||||
|
|
||||||
|
@ -26,10 +27,10 @@ class BookSearch(TestCase):
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
isbn_10="1111111111",
|
isbn_10="1111111111",
|
||||||
openlibrary_key="hello",
|
openlibrary_key="hello",
|
||||||
|
pages=150,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.third_edition = models.Edition.objects.create(
|
self.third_edition = models.Edition.objects.create(
|
||||||
title="Edition with annoying ISBN",
|
title="Another Edition with annoying ISBN",
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
isbn_10="022222222X",
|
isbn_10="022222222X",
|
||||||
)
|
)
|
||||||
|
@ -76,16 +77,21 @@ class BookSearch(TestCase):
|
||||||
|
|
||||||
def test_search_title_author(self):
|
def test_search_title_author(self):
|
||||||
"""search by unique identifiers"""
|
"""search by unique identifiers"""
|
||||||
results = book_search.search_title_author("Another", min_confidence=0)
|
results = book_search.search_title_author("annoying", min_confidence=0)
|
||||||
self.assertEqual(len(results), 1)
|
self.assertEqual(len(results), 1)
|
||||||
self.assertEqual(results[0], self.second_edition)
|
self.assertEqual(results[0], self.third_edition)
|
||||||
|
|
||||||
def test_search_title_author_return_first(self):
|
def test_search_title_author_return_first(self):
|
||||||
"""search by unique identifiers"""
|
"""sorts by edition rank"""
|
||||||
results = book_search.search_title_author(
|
result = book_search.search_title_author(
|
||||||
"Another", min_confidence=0, return_first=True
|
"Another", min_confidence=0, return_first=True
|
||||||
)
|
)
|
||||||
self.assertEqual(results, self.second_edition)
|
self.assertEqual(result, self.second_edition) # highest edition rank
|
||||||
|
|
||||||
|
def test_search_title_author_one_edition_per_work(self):
|
||||||
|
"""at most one edition per work"""
|
||||||
|
results = book_search.search_title_author("Edition", 0)
|
||||||
|
self.assertEqual(results, [self.first_edition]) # highest edition rank
|
||||||
|
|
||||||
def test_format_search_result(self):
|
def test_format_search_result(self):
|
||||||
"""format a search result"""
|
"""format a search result"""
|
||||||
|
|
|
@ -11,9 +11,9 @@ from bookwyrm.context_processors import site_settings
|
||||||
class ContextProcessor(TestCase):
|
class ContextProcessor(TestCase):
|
||||||
"""pages you land on without really trying"""
|
"""pages you land on without really trying"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -28,6 +28,10 @@ class ContextProcessor(TestCase):
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
self.site = models.SiteSettings.objects.create()
|
self.site = models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""other test data"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_theme_unset(self):
|
def test_theme_unset(self):
|
||||||
"""logged in user, no selected theme"""
|
"""logged in user, no selected theme"""
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
|
|
|
@ -11,10 +11,9 @@ from bookwyrm import emailing, models
|
||||||
class Emailing(TestCase):
|
class Emailing(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -27,6 +26,10 @@ class Emailing(TestCase):
|
||||||
)
|
)
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""other test data"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_invite_email(self, email_mock):
|
def test_invite_email(self, email_mock):
|
||||||
"""load the invite email"""
|
"""load the invite email"""
|
||||||
invite_request = models.InviteRequest.objects.create(
|
invite_request = models.InviteRequest.objects.create(
|
||||||
|
|
|
@ -35,8 +35,8 @@ Sender = namedtuple("Sender", ("remote_id", "key_pair"))
|
||||||
class Signature(TestCase):
|
class Signature(TestCase):
|
||||||
"""signature test"""
|
"""signature test"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""create users and test data"""
|
"""create users and test data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -54,15 +54,15 @@ class Signature(TestCase):
|
||||||
self.cat = models.User.objects.create_user(
|
self.cat = models.User.objects.create_user(
|
||||||
f"cat@{DOMAIN}", "cat@example.com", "", local=True, localname="cat"
|
f"cat@{DOMAIN}", "cat@example.com", "", local=True, localname="cat"
|
||||||
)
|
)
|
||||||
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""test data"""
|
||||||
private_key, public_key = create_key_pair()
|
private_key, public_key = create_key_pair()
|
||||||
|
|
||||||
self.fake_remote = Sender(
|
self.fake_remote = Sender(
|
||||||
"http://localhost/user/remote", KeyPair(private_key, public_key)
|
"http://localhost/user/remote", KeyPair(private_key, public_key)
|
||||||
)
|
)
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
|
||||||
|
|
||||||
def send(self, signature, now, data, digest):
|
def send(self, signature, now, data, digest):
|
||||||
"""test request"""
|
"""test request"""
|
||||||
client = Client()
|
client = Client()
|
||||||
|
|
|
@ -8,6 +8,7 @@ def validate_html(html):
|
||||||
_, errors = tidy_document(
|
_, errors = tidy_document(
|
||||||
html.content,
|
html.content,
|
||||||
options={
|
options={
|
||||||
|
"doctype": "html5",
|
||||||
"drop-empty-elements": False,
|
"drop-empty-elements": False,
|
||||||
"warn-proprietary-attributes": False,
|
"warn-proprietary-attributes": False,
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,9 +11,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class AnnouncementViews(TestCase):
|
class AnnouncementViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -27,6 +27,10 @@ class AnnouncementViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_announcements_page(self):
|
def test_announcements_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
models.Announcement.objects.create(preview="hi", user=self.local_user)
|
models.Announcement.objects.create(preview="hi", user=self.local_user)
|
||||||
|
|
|
@ -15,10 +15,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class AutomodViews(TestCase):
|
class AutomodViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -35,6 +34,10 @@ class AutomodViews(TestCase):
|
||||||
self.local_user.groups.set([group])
|
self.local_user.groups.set([group])
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_automod_rules_get(self):
|
def test_automod_rules_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
schedule = IntervalSchedule.objects.create(every=1, period="days")
|
schedule = IntervalSchedule.objects.create(every=1, period="days")
|
||||||
|
|
|
@ -14,10 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class CeleryStatusViews(TestCase):
|
class CeleryStatusViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -34,6 +33,10 @@ class CeleryStatusViews(TestCase):
|
||||||
self.local_user.groups.set([group])
|
self.local_user.groups.set([group])
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_celery_status_get(self):
|
def test_celery_status_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.CeleryStatus.as_view()
|
view = views.CeleryStatus.as_view()
|
||||||
|
|
|
@ -14,9 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class DashboardViews(TestCase):
|
class DashboardViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -34,6 +34,10 @@ class DashboardViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_dashboard(self):
|
def test_dashboard(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Dashboard.as_view()
|
view = views.Dashboard.as_view()
|
||||||
|
|
|
@ -14,9 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class EmailBlocklistViews(TestCase):
|
class EmailBlocklistViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -34,6 +34,10 @@ class EmailBlocklistViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_blocklist_page_get(self):
|
def test_blocklist_page_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.EmailBlocklist.as_view()
|
view = views.EmailBlocklist.as_view()
|
||||||
|
|
|
@ -14,10 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class EmailConfigViews(TestCase):
|
class EmailConfigViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -34,6 +33,10 @@ class EmailConfigViews(TestCase):
|
||||||
self.local_user.groups.set([group])
|
self.local_user.groups.set([group])
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_email_config_get(self):
|
def test_email_config_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.EmailConfig.as_view()
|
view = views.EmailConfig.as_view()
|
||||||
|
|
|
@ -17,10 +17,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class FederationViews(TestCase):
|
class FederationViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -48,6 +47,10 @@ class FederationViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_federation_page(self):
|
def test_federation_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Federation.as_view()
|
view = views.Federation.as_view()
|
||||||
|
|
|
@ -14,10 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class ImportsAdminViews(TestCase):
|
class ImportsAdminViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -34,6 +33,10 @@ class ImportsAdminViews(TestCase):
|
||||||
self.local_user.groups.set([group])
|
self.local_user.groups.set([group])
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_celery_status_get(self):
|
def test_celery_status_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.ImportList.as_view()
|
view = views.ImportList.as_view()
|
||||||
|
|
|
@ -14,9 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class IPBlocklistViews(TestCase):
|
class IPBlocklistViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -34,6 +34,10 @@ class IPBlocklistViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_blocklist_page_get(self):
|
def test_blocklist_page_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.IPBlocklist.as_view()
|
view = views.IPBlocklist.as_view()
|
||||||
|
|
|
@ -14,9 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class LinkDomainViews(TestCase):
|
class LinkDomainViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -41,6 +41,10 @@ class LinkDomainViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_domain_page_get(self):
|
def test_domain_page_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.LinkDomain.as_view()
|
view = views.LinkDomain.as_view()
|
||||||
|
|
|
@ -15,10 +15,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class ReportViews(TestCase):
|
class ReportViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -42,6 +41,10 @@ class ReportViews(TestCase):
|
||||||
self.local_user.groups.set([group])
|
self.local_user.groups.set([group])
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_reports_page(self):
|
def test_reports_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.ReportsAdmin.as_view()
|
view = views.ReportsAdmin.as_view()
|
||||||
|
|
|
@ -14,10 +14,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class SiteSettingsViews(TestCase):
|
class SiteSettingsViews(TestCase):
|
||||||
"""Edit site settings"""
|
"""Edit site settings"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -35,6 +34,10 @@ class SiteSettingsViews(TestCase):
|
||||||
|
|
||||||
self.site = models.SiteSettings.objects.create()
|
self.site = models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_site_get(self):
|
def test_site_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Site.as_view()
|
view = views.Site.as_view()
|
||||||
|
|
|
@ -15,10 +15,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class AdminThemesViews(TestCase):
|
class AdminThemesViews(TestCase):
|
||||||
"""Edit site settings"""
|
"""Edit site settings"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -43,6 +42,10 @@ class AdminThemesViews(TestCase):
|
||||||
|
|
||||||
self.site = models.SiteSettings.objects.create()
|
self.site = models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_themes_get(self):
|
def test_themes_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Themes.as_view()
|
view = views.Themes.as_view()
|
||||||
|
|
|
@ -15,9 +15,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class UserAdminViews(TestCase):
|
class UserAdminViews(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -34,6 +34,10 @@ class UserAdminViews(TestCase):
|
||||||
self.local_user.groups.set([group])
|
self.local_user.groups.set([group])
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_user_admin_list_page(self):
|
def test_user_admin_list_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.UserAdminList.as_view()
|
view = views.UserAdminList.as_view()
|
||||||
|
|
|
@ -23,9 +23,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class BookViews(TestCase):
|
class BookViews(TestCase):
|
||||||
"""books books books"""
|
"""books books books"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -54,6 +54,10 @@ class BookViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_book_page(self):
|
def test_book_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Book.as_view()
|
view = views.Book.as_view()
|
||||||
|
|
|
@ -19,9 +19,9 @@ from bookwyrm.tests.views.books.test_book import _setup_cover_url
|
||||||
class EditBookViews(TestCase):
|
class EditBookViews(TestCase):
|
||||||
"""books books books"""
|
"""books books books"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -47,10 +47,13 @@ class EditBookViews(TestCase):
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
)
|
)
|
||||||
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
# pylint: disable=line-too-long
|
# pylint: disable=line-too-long
|
||||||
self.authors_body = "<?xml version='1.0' encoding='UTF-8' ?><?xml-stylesheet type='text/xsl' href='http://isni.oclc.org/sru/DB=1.2/?xsl=searchRetrieveResponse' ?><srw:searchRetrieveResponse xmlns:srw='http://www.loc.gov/zing/srw/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:diag='http://www.loc.gov/zing/srw/diagnostic/' xmlns:xcql='http://www.loc.gov/zing/cql/xcql/'><srw:version>1.1</srw:version><srw:records><srw:record><isniUnformatted>0000000084510024</isniUnformatted></srw:record></srw:records></srw:searchRetrieveResponse>"
|
self.authors_body = "<?xml version='1.0' encoding='UTF-8' ?><?xml-stylesheet type='text/xsl' href='http://isni.oclc.org/sru/DB=1.2/?xsl=searchRetrieveResponse' ?><srw:searchRetrieveResponse xmlns:srw='http://www.loc.gov/zing/srw/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:diag='http://www.loc.gov/zing/srw/diagnostic/' xmlns:xcql='http://www.loc.gov/zing/cql/xcql/'><srw:version>1.1</srw:version><srw:records><srw:record><isniUnformatted>0000000084510024</isniUnformatted></srw:record></srw:records></srw:searchRetrieveResponse>"
|
||||||
|
|
||||||
# pylint: disable=line-too-long
|
|
||||||
self.author_body = "<?xml version='1.0' encoding='UTF-8' ?><?xml-stylesheet type='text/xsl' href='http://isni.oclc.org/sru/DB=1.2/?xsl=searchRetrieveResponse' ?><srw:searchRetrieveResponse xmlns:srw='http://www.loc.gov/zing/srw/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:diag='http://www.loc.gov/zing/srw/diagnostic/' xmlns:xcql='http://www.loc.gov/zing/cql/xcql/'><srw:records><srw:record><srw:recordData><responseRecord><ISNIAssigned><isniUnformatted>0000000084510024</isniUnformatted><isniURI>https://isni.org/isni/0000000084510024</isniURI><dataConfidence>60</dataConfidence><ISNIMetadata><identity><personOrFiction><personalName><surname>Catherine Amy Dawson Scott</surname><nameTitle>poet and novelist</nameTitle><nameUse>public</nameUse><source>VIAF</source><source>WKP</source><subsourceIdentifier>Q544961</subsourceIdentifier></personalName><personalName><forename>C. A.</forename><surname>Dawson Scott</surname><marcDate>1865-1934</marcDate><nameUse>public</nameUse><source>VIAF</source><source>NLP</source><subsourceIdentifier>a28927850</subsourceIdentifier></personalName><sources><codeOfSource>VIAF</codeOfSource><sourceIdentifier>45886165</sourceIdentifier><reference><class>ALL</class><role>CRE</role><URI>http://viaf.org/viaf/45886165</URI></reference></sources><externalInformation><information>Wikipedia</information><URI>https://en.wikipedia.org/wiki/Catherine_Amy_Dawson_Scott</URI></externalInformation></ISNIMetadata></ISNIAssigned></responseRecord></srw:recordData></srw:record></srw:records></srw:searchRetrieveResponse>"
|
self.author_body = "<?xml version='1.0' encoding='UTF-8' ?><?xml-stylesheet type='text/xsl' href='http://isni.oclc.org/sru/DB=1.2/?xsl=searchRetrieveResponse' ?><srw:searchRetrieveResponse xmlns:srw='http://www.loc.gov/zing/srw/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:diag='http://www.loc.gov/zing/srw/diagnostic/' xmlns:xcql='http://www.loc.gov/zing/cql/xcql/'><srw:records><srw:record><srw:recordData><responseRecord><ISNIAssigned><isniUnformatted>0000000084510024</isniUnformatted><isniURI>https://isni.org/isni/0000000084510024</isniURI><dataConfidence>60</dataConfidence><ISNIMetadata><identity><personOrFiction><personalName><surname>Catherine Amy Dawson Scott</surname><nameTitle>poet and novelist</nameTitle><nameUse>public</nameUse><source>VIAF</source><source>WKP</source><subsourceIdentifier>Q544961</subsourceIdentifier></personalName><personalName><forename>C. A.</forename><surname>Dawson Scott</surname><marcDate>1865-1934</marcDate><nameUse>public</nameUse><source>VIAF</source><source>NLP</source><subsourceIdentifier>a28927850</subsourceIdentifier></personalName><sources><codeOfSource>VIAF</codeOfSource><sourceIdentifier>45886165</sourceIdentifier><reference><class>ALL</class><role>CRE</role><URI>http://viaf.org/viaf/45886165</URI></reference></sources><externalInformation><information>Wikipedia</information><URI>https://en.wikipedia.org/wiki/Catherine_Amy_Dawson_Scott</URI></externalInformation></ISNIMetadata></ISNIAssigned></responseRecord></srw:recordData></srw:record></srw:records></srw:searchRetrieveResponse>"
|
||||||
|
|
||||||
responses.get(
|
responses.get(
|
||||||
|
@ -86,8 +89,6 @@ class EditBookViews(TestCase):
|
||||||
body=self.author_body,
|
body=self.author_body,
|
||||||
)
|
)
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
|
||||||
|
|
||||||
def test_edit_book_get(self):
|
def test_edit_book_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.EditBook.as_view()
|
view = views.EditBook.as_view()
|
||||||
|
|
|
@ -13,9 +13,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class BookViews(TestCase):
|
class BookViews(TestCase):
|
||||||
"""books books books"""
|
"""books books books"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -37,6 +37,10 @@ class BookViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_editions_page(self):
|
def test_editions_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Editions.as_view()
|
view = views.Editions.as_view()
|
||||||
|
|
|
@ -15,10 +15,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class LinkViews(TestCase):
|
class LinkViews(TestCase):
|
||||||
"""books books books"""
|
"""books books books"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
):
|
):
|
||||||
|
@ -49,6 +48,10 @@ class LinkViews(TestCase):
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_add_link_page(self):
|
def test_add_link_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.AddFileLink.as_view()
|
view = views.AddFileLink.as_view()
|
||||||
|
|
|
@ -16,10 +16,9 @@ from bookwyrm.tests.validate_html import validate_html
|
||||||
class ImportViews(TestCase):
|
class ImportViews(TestCase):
|
||||||
"""goodreads import views"""
|
"""goodreads import views"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -32,6 +31,10 @@ class ImportViews(TestCase):
|
||||||
)
|
)
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_import_page(self):
|
def test_import_page(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Import.as_view()
|
view = views.Import.as_view()
|
||||||
|
|
|
@ -11,10 +11,9 @@ from bookwyrm import models, views
|
||||||
class ImportManualReviewViews(TestCase):
|
class ImportManualReviewViews(TestCase):
|
||||||
"""goodreads import views"""
|
"""goodreads import views"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -35,6 +34,10 @@ class ImportManualReviewViews(TestCase):
|
||||||
parent_work=work,
|
parent_work=work,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_import_troubleshoot_get(self):
|
def test_import_troubleshoot_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.ImportManualReview.as_view()
|
view = views.ImportManualReview.as_view()
|
||||||
|
|
|
@ -12,10 +12,9 @@ from bookwyrm import models, views
|
||||||
class ImportTroubleshootViews(TestCase):
|
class ImportTroubleshootViews(TestCase):
|
||||||
"""goodreads import views"""
|
"""goodreads import views"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -28,6 +27,10 @@ class ImportTroubleshootViews(TestCase):
|
||||||
)
|
)
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
def test_import_troubleshoot_get(self):
|
def test_import_troubleshoot_get(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.ImportTroubleshoot.as_view()
|
view = views.ImportTroubleshoot.as_view()
|
||||||
|
|
|
@ -15,12 +15,22 @@ from bookwyrm import models, views
|
||||||
class Inbox(TestCase):
|
class Inbox(TestCase):
|
||||||
"""readthrough tests"""
|
"""readthrough tests"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""basic user and book data"""
|
"""individual test setup"""
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
|
self.create_json = {
|
||||||
|
"id": "hi",
|
||||||
|
"type": "Create",
|
||||||
|
"actor": "hi",
|
||||||
|
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
||||||
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
|
"object": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
|
@ -43,14 +53,6 @@ class Inbox(TestCase):
|
||||||
inbox="https://example.com/users/rat/inbox",
|
inbox="https://example.com/users/rat/inbox",
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
self.create_json = {
|
|
||||||
"id": "hi",
|
|
||||||
"type": "Create",
|
|
||||||
"actor": "hi",
|
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
|
||||||
"object": {},
|
|
||||||
}
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_inbox_invalid_get(self):
|
def test_inbox_invalid_get(self):
|
||||||
|
|
|
@ -11,7 +11,8 @@ from bookwyrm import models, views
|
||||||
class InboxAdd(TestCase):
|
class InboxAdd(TestCase):
|
||||||
"""inbox tests"""
|
"""inbox tests"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -11,7 +11,8 @@ from bookwyrm import models, views
|
||||||
class InboxActivities(TestCase):
|
class InboxActivities(TestCase):
|
||||||
"""inbox tests"""
|
"""inbox tests"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -44,6 +45,10 @@ class InboxActivities(TestCase):
|
||||||
remote_id="https://example.com/status/1",
|
remote_id="https://example.com/status/1",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
self.create_json = {
|
self.create_json = {
|
||||||
"id": "hi",
|
"id": "hi",
|
||||||
"type": "Create",
|
"type": "Create",
|
||||||
|
@ -53,8 +58,6 @@ class InboxActivities(TestCase):
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
|
||||||
|
|
||||||
@patch("bookwyrm.activitystreams.handle_boost_task.delay")
|
@patch("bookwyrm.activitystreams.handle_boost_task.delay")
|
||||||
def test_boost(self, _):
|
def test_boost(self, _):
|
||||||
"""boost a status"""
|
"""boost a status"""
|
||||||
|
|
|
@ -10,7 +10,8 @@ from bookwyrm import models, views
|
||||||
class InboxBlock(TestCase):
|
class InboxBlock(TestCase):
|
||||||
"""inbox tests"""
|
"""inbox tests"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -9,7 +9,7 @@ from bookwyrm import models, views
|
||||||
from bookwyrm.activitypub import ActivitySerializerError
|
from bookwyrm.activitypub import ActivitySerializerError
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-public-methods, invalid-name
|
# pylint: disable=too-many-public-methods
|
||||||
class TransactionInboxCreate(TransactionTestCase):
|
class TransactionInboxCreate(TransactionTestCase):
|
||||||
"""readthrough tests"""
|
"""readthrough tests"""
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ class TransactionInboxCreate(TransactionTestCase):
|
||||||
class InboxCreate(TestCase):
|
class InboxCreate(TestCase):
|
||||||
"""readthrough tests"""
|
"""readthrough tests"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
@ -96,6 +97,10 @@ class InboxCreate(TestCase):
|
||||||
outbox="https://example.com/users/rat/outbox",
|
outbox="https://example.com/users/rat/outbox",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""individual test setup"""
|
||||||
self.create_json = {
|
self.create_json = {
|
||||||
"id": "hi",
|
"id": "hi",
|
||||||
"type": "Create",
|
"type": "Create",
|
||||||
|
@ -104,7 +109,6 @@ class InboxCreate(TestCase):
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
"object": {},
|
"object": {},
|
||||||
}
|
}
|
||||||
models.SiteSettings.objects.create()
|
|
||||||
|
|
||||||
def test_create_status(self, *_):
|
def test_create_status(self, *_):
|
||||||
"""the "it justs works" mode"""
|
"""the "it justs works" mode"""
|
||||||
|
|
|
@ -11,8 +11,8 @@ from bookwyrm import models, views
|
||||||
class InboxActivities(TestCase):
|
class InboxActivities(TestCase):
|
||||||
"""inbox tests"""
|
"""inbox tests"""
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
@classmethod
|
||||||
def setUp(self):
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
|
@ -11,7 +11,8 @@ from bookwyrm import models, views
|
||||||
class InboxRelationships(TestCase):
|
class InboxRelationships(TestCase):
|
||||||
"""inbox tests"""
|
"""inbox tests"""
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue