1
0
Fork 0

Merge branch 'main' into user-migration

This commit is contained in:
Hugh Rundle 2023-11-13 21:17:07 +11:00 committed by GitHub
commit d5762f1d52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 487 additions and 166 deletions

View file

@ -11,6 +11,7 @@ from bookwyrm import models, views
class InboxActivities(TestCase):
"""inbox tests"""
# pylint: disable=invalid-name
def setUp(self):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
@ -97,7 +98,8 @@ class InboxActivities(TestCase):
self.assertEqual(models.Notification.objects.get(), notif)
@patch("bookwyrm.suggested_users.remove_user_task.delay")
def test_delete_user(self, _):
@patch("bookwyrm.activitystreams.remove_status_task.delay")
def test_delete_user(self, *_):
"""delete a user"""
self.assertTrue(models.User.objects.get(username="rat@example.com").is_active)
activity = {

View file

@ -420,21 +420,25 @@ http://www.fish.com/"""
'okay\n\n<a href="http://www.fish.com/">www.fish.com/</a>',
)
def test_format_links_parens(self, *_):
"""find and format urls into a tags"""
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_punctuation(self, *_):
"""dont 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>.',
)
"""test many combinations of brackets, URLs, and punctuation"""
url = "https://bookwyrm.social"
html = f'<a href="{url}">bookwyrm.social</a>'
test_table = [
("punct", f"text and {url}.", f"text and {html}."),
("multi_punct", f"text, then {url}?...", f"text, then {html}?..."),
("bracket_punct", f"here ({url}).", f"here ({html})."),
("punct_bracket", f"there [{url}?]", f"there [{html}?]"),
("punct_bracket_punct", f"not here? ({url}!).", f"not here? ({html}!)."),
(
"multi_punct_bracket",
f"not there ({url}...);",
f"not there ({html}...);",
),
]
for desc, text, output in test_table:
with self.subTest(desc=desc):
self.assertEqual(views.status.format_links(text), output)
def test_format_links_special_chars(self, *_):
"""find and format urls into a tags"""
@ -464,6 +468,13 @@ http://www.fish.com/"""
views.status.format_links(url), f'<a href="{url}">{url[8:]}</a>'
)
def test_format_links_ignore_non_urls(self, *_):
"""formating links should leave plain text untouced"""
text_elision = "> “The distinction is significant.” [...]" # bookwyrm#2993
text_quoteparens = "some kind of gene-editing technology (?)" # bookwyrm#3049
self.assertEqual(views.status.format_links(text_elision), text_elision)
self.assertEqual(views.status.format_links(text_quoteparens), text_quoteparens)
def test_format_mentions_with_at_symbol_links(self, *_):
"""A link with an @username shouldn't treat the username as a mention"""
content = "a link to https://example.com/user/@mouse"