Save and continue from get started books view

This commit is contained in:
Mouse Reeve
2021-04-01 09:02:48 -07:00
parent e2388d8f67
commit ed127f4e07
4 changed files with 72 additions and 8 deletions

View File

@ -25,6 +25,9 @@ class GetStartedViews(TestCase):
title="Example Edition",
remote_id="https://example.com/book/1",
)
models.Connector.objects.create(
identifier="self", connector_file="self_connector", local=True
)
models.SiteSettings.objects.create()
def test_profile_view(self):
@ -69,6 +72,36 @@ class GetStartedViews(TestCase):
result.render()
self.assertEqual(result.status_code, 200)
def test_books_view_with_query(self):
""" there are so many views, this just makes sure it LOADS """
view = views.GetStartedBooks.as_view()
request = self.factory.get("?query=Example")
request.user = self.local_user
result = view(request)
self.assertIsInstance(result, TemplateResponse)
result.render()
self.assertEqual(result.status_code, 200)
def test_books_view_post(self):
""" shelve some books """
view = views.GetStartedBooks.as_view()
data = {self.book.id: self.local_user.shelf_set.first().id}
request = self.factory.post("", data)
request.user = self.local_user
self.assertFalse(self.local_user.shelfbook_set.exists())
with patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.delay"
) as delay_mock:
view(request)
self.assertEqual(delay_mock.call_count, 1)
shelfbook = self.local_user.shelfbook_set.first()
self.assertEqual(shelfbook.book, self.book)
self.assertEqual(shelfbook.user, self.local_user)
def test_users_view(self):
""" there are so many views, this just makes sure it LOADS """
view = views.GetStartedUsers.as_view()