Merge pull request #561 from mouse-reeve/views-tests

Views tests
This commit is contained in:
Mouse Reeve 2021-01-27 11:10:34 -08:00 committed by GitHub
commit 5e885e7bda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 10 deletions

View file

@ -0,0 +1 @@
from . import *

View file

@ -45,7 +45,8 @@ class ReadingViews(TestCase):
'start_date': '2020-01-05',
})
request.user = self.local_user
views.start_reading(request, self.book.id)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
views.start_reading(request, self.book.id)
self.assertEqual(shelf.books.get(), self.book)
@ -73,7 +74,8 @@ class ReadingViews(TestCase):
request = self.factory.post('')
request.user = self.local_user
views.start_reading(request, self.book.id)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
views.start_reading(request, self.book.id)
self.assertFalse(to_read_shelf.books.exists())
self.assertEqual(shelf.books.get(), self.book)
@ -95,7 +97,9 @@ class ReadingViews(TestCase):
'id': readthrough.id,
})
request.user = self.local_user
views.finish_reading(request, self.book.id)
with patch('bookwyrm.broadcast.broadcast_task.delay'):
views.finish_reading(request, self.book.id)
self.assertEqual(shelf.books.get(), self.book)

View file

@ -74,7 +74,7 @@ class ShelfViews(TestCase):
'name': 'To Read',
})
request.user = self.local_user
view(request, self.local_user.username, shelf.id)
view(request, self.local_user.username, shelf.identifier)
shelf.refresh_from_db()
self.assertEqual(shelf.privacy, 'unlisted')
@ -94,7 +94,7 @@ class ShelfViews(TestCase):
'name': 'cool name'
})
request.user = self.local_user
view(request, request.user.username, shelf.id)
view(request, request.user.username, shelf.identifier)
shelf.refresh_from_db()
self.assertEqual(shelf.name, 'cool name')
@ -114,7 +114,7 @@ class ShelfViews(TestCase):
'name': 'cool name'
})
request.user = self.local_user
view(request, request.user.username, shelf.id)
view(request, request.user.username, shelf.identifier)
self.assertEqual(shelf.name, 'To Read')

View file

@ -176,7 +176,8 @@ class StatusViews(TestCase):
reply = models.Status.replies(status).first()
self.assertEqual(reply.content, '<p>right</p>')
self.assertEqual(reply.user, user)
self.assertTrue(self.remote_user in reply.mention_users.all())
# the mentioned user in the parent post is only included if @'ed
self.assertFalse(self.remote_user in reply.mention_users.all())
self.assertTrue(self.local_user in reply.mention_users.all())
def test_find_mentions(self):

View file

@ -30,8 +30,8 @@ def start_reading(request, book_id):
if readthrough:
readthrough.save()
# create a progress update if we have a page
readthrough.create_update()
# create a progress update if we have a page
readthrough.create_update()
# shelve the book
if request.POST.get('reshelve', True):

View file

@ -65,6 +65,7 @@ class Shelf(View):
return TemplateResponse(request, 'shelf.html', data)
@method_decorator(login_required, name='dispatch')
# pylint: disable=unused-argument
def post(self, request, username, shelf_identifier):
''' edit a shelf '''
try:

View file

@ -73,7 +73,7 @@ class User(View):
activities = get_activity_feed(
request.user,
['public', 'unlisted', 'followers'],
queryset=models.Status.objects.filter(user=user)
queryset=user.status_set
)
paginated = Paginator(activities, PAGE_LENGTH)
goal = models.AnnualGoal.objects.filter(