Test users with domains that contain dashes

This commit is contained in:
Mouse Reeve 2021-12-28 15:52:35 -08:00
parent 1a30546b99
commit 14a90e805a

View file

@ -80,6 +80,29 @@ class UserViews(TestCase):
self.assertIsInstance(result, ActivitypubResponse) self.assertIsInstance(result, ActivitypubResponse)
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
def test_user_page_domain(self):
"""when the user domain has dashes in it"""
with patch("bookwyrm.models.user.set_remote_server"):
self.remote_user = models.User.objects.create_user(
"nutria",
"",
"nutriaword",
local=False,
remote_id="https://ex--ample.co----m/users/nutria",
inbox="https://ex--ample.co----m/users/nutria/inbox",
outbox="https://ex--ample.co----m/users/nutria/outbox",
)
view = views.User.as_view()
request = self.factory.get("")
request.user = self.local_user
with patch("bookwyrm.views.user.is_api_request") as is_api:
is_api.return_value = False
result = view(request, "nutria@ex--ample.co----m")
self.assertIsInstance(result, TemplateResponse)
validate_html(result.render())
self.assertEqual(result.status_code, 200)
def test_user_page_blocked(self): def test_user_page_blocked(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.User.as_view() view = views.User.as_view()