Merge branch 'main' into report-actions
This commit is contained in:
commit
a166af9990
88 changed files with 15768 additions and 326 deletions
|
@ -347,11 +347,17 @@ class RegisterViews(TestCase):
|
|||
self.settings.save()
|
||||
|
||||
self.local_user.is_active = False
|
||||
self.local_user.allow_reactivation = True
|
||||
self.local_user.deactivation_reason = "pending"
|
||||
self.local_user.confirmation_code = "12345"
|
||||
self.local_user.save(
|
||||
broadcast=False,
|
||||
update_fields=["is_active", "deactivation_reason", "confirmation_code"],
|
||||
update_fields=[
|
||||
"is_active",
|
||||
"allow_reactivation",
|
||||
"deactivation_reason",
|
||||
"confirmation_code",
|
||||
],
|
||||
)
|
||||
view = views.ConfirmEmailCode.as_view()
|
||||
request = self.factory.get("")
|
||||
|
|
|
@ -141,3 +141,24 @@ class DeleteUserViews(TestCase):
|
|||
self.local_user.refresh_from_db()
|
||||
self.assertTrue(self.local_user.is_active)
|
||||
self.assertIsNone(self.local_user.deactivation_reason)
|
||||
|
||||
def test_reactivate_user_post_disallowed(self, _):
|
||||
"""Reactivate action under the wrong circumstances"""
|
||||
self.local_user.is_active = False
|
||||
self.local_user.save(broadcast=False)
|
||||
|
||||
view = views.ReactivateUser.as_view()
|
||||
form = forms.LoginForm()
|
||||
form.data["localname"] = "mouse"
|
||||
form.data["password"] = "password"
|
||||
request = self.factory.post("", form.data)
|
||||
request.user = self.local_user
|
||||
middleware = SessionMiddleware()
|
||||
middleware.process_request(request)
|
||||
request.session.save()
|
||||
|
||||
with patch("bookwyrm.views.preferences.delete_user.login"):
|
||||
view(request)
|
||||
|
||||
self.local_user.refresh_from_db()
|
||||
self.assertFalse(self.local_user.is_active)
|
||||
|
|
|
@ -62,7 +62,7 @@ class StatusTransactions(TransactionTestCase):
|
|||
with patch("bookwyrm.activitystreams.add_status_task.apply_async") as mock:
|
||||
view(request, "comment")
|
||||
|
||||
self.assertEqual(mock.call_count, 2)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
|
||||
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
|
@ -428,6 +428,14 @@ http://www.fish.com/"""
|
|||
f'(<a href="{url}">www.fish.com/</a>)',
|
||||
)
|
||||
|
||||
def test_format_links_punctuation(self, *_):
|
||||
"""don’t take trailing punctuation into account pls"""
|
||||
url = "http://www.fish.com/"
|
||||
self.assertEqual(
|
||||
views.status.format_links(f"{url}."),
|
||||
f'<a href="{url}">www.fish.com/</a>.',
|
||||
)
|
||||
|
||||
def test_format_links_special_chars(self, *_):
|
||||
"""find and format urls into a tags"""
|
||||
url = "https://archive.org/details/dli.granth.72113/page/n25/mode/2up"
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.http.response import Http404
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import TestCase
|
||||
from django.test import Client, TestCase
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
from bookwyrm import models, views
|
||||
|
@ -152,6 +152,30 @@ class UserViews(TestCase):
|
|||
validate_html(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
def test_user_page_remote_anonymous(self):
|
||||
"""when a anonymous user tries to get a remote user"""
|
||||
with patch("bookwyrm.models.user.set_remote_server"):
|
||||
models.User.objects.create_user(
|
||||
"nutria",
|
||||
"",
|
||||
"nutriaword",
|
||||
local=False,
|
||||
remote_id="https://example.com/users/nutria",
|
||||
inbox="https://example.com/users/nutria/inbox",
|
||||
outbox="https://example.com/users/nutria/outbox",
|
||||
)
|
||||
|
||||
view = views.User.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.anonymous_user
|
||||
with patch("bookwyrm.views.user.is_api_request") as is_api:
|
||||
is_api.return_value = False
|
||||
result = view(request, "nutria@example.com")
|
||||
result.client = Client()
|
||||
self.assertRedirects(
|
||||
result, "https://example.com/users/nutria", fetch_redirect_response=False
|
||||
)
|
||||
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
def test_followers_page_blocked(self, *_):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue