forked from mirrors/bookwyrm
Adds views test
This commit is contained in:
parent
fcd41aaf06
commit
47dbcc3af0
1 changed files with 44 additions and 0 deletions
|
@ -91,6 +91,50 @@ class ListViews(TestCase):
|
|||
result.render()
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
def test_bookmarked_lists_page(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.BookmarkedLists.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
booklist = models.List.objects.create(name="Public list", user=self.local_user)
|
||||
models.List.objects.create(
|
||||
name="Private list", privacy="direct", user=self.local_user
|
||||
)
|
||||
self.local_user.saved_lists.add(booklist)
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
result.render()
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(result.context_data["lists"].object_list, [booklist])
|
||||
|
||||
def test_bookmarked_lists_page_empty(self):
|
||||
"""there are so many views, this just makes sure it LOADS"""
|
||||
view = views.BookmarkedLists.as_view()
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
models.List.objects.create(name="Public list", user=self.local_user)
|
||||
models.List.objects.create(
|
||||
name="Private list", privacy="direct", user=self.local_user
|
||||
)
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
result.render()
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(result.context_data["lists"].object_list, [])
|
||||
|
||||
def test_bookmarked_lists_page_logged_out(self):
|
||||
"""logged out bookmarked lists"""
|
||||
view = views.BookmarkedLists.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.anonymous_user
|
||||
|
||||
result = view(request)
|
||||
self.assertEqual(result.status_code, 301)
|
||||
|
||||
def test_lists_create(self):
|
||||
"""create list view"""
|
||||
view = views.Lists.as_view()
|
||||
|
|
Loading…
Reference in a new issue