mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 21:11:16 +00:00
Handle invalid status urls with 404
This commit is contained in:
parent
d021666f2b
commit
0365a57307
2 changed files with 13 additions and 1 deletions
|
@ -66,6 +66,18 @@ class FeedViews(TestCase):
|
||||||
self.assertIsInstance(result, ActivitypubResponse)
|
self.assertIsInstance(result, ActivitypubResponse)
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
|
def test_status_page_not_found(self, *_):
|
||||||
|
""" there are so many views, this just makes sure it LOADS """
|
||||||
|
view = views.Status.as_view()
|
||||||
|
|
||||||
|
request = self.factory.get("")
|
||||||
|
request.user = self.local_user
|
||||||
|
with patch("bookwyrm.views.feed.is_api_request") as is_api:
|
||||||
|
is_api.return_value = False
|
||||||
|
result = view(request, "mouse", 12345)
|
||||||
|
|
||||||
|
self.assertEqual(result.status_code, 404)
|
||||||
|
|
||||||
def test_status_page_with_image(self, *_):
|
def test_status_page_with_image(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.Status.as_view()
|
view = views.Status.as_view()
|
||||||
|
|
|
@ -115,7 +115,7 @@ class Status(View):
|
||||||
status = models.Status.objects.select_subclasses().get(
|
status = models.Status.objects.select_subclasses().get(
|
||||||
id=status_id, deleted=False
|
id=status_id, deleted=False
|
||||||
)
|
)
|
||||||
except ValueError:
|
except (ValueError, models.Status.DoesNotExist):
|
||||||
return HttpResponseNotFound()
|
return HttpResponseNotFound()
|
||||||
|
|
||||||
# the url should have the poster's username in it
|
# the url should have the poster's username in it
|
||||||
|
|
Loading…
Reference in a new issue