mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-22 08:07:14 +00:00
Fixes status tests and adds delete test
This commit is contained in:
parent
5596277d29
commit
c8efa1ffc8
1 changed files with 17 additions and 3 deletions
|
@ -43,14 +43,14 @@ class StatusViews(TestCase):
|
|||
content='hi', user=self.local_user)
|
||||
request = self.factory.get('')
|
||||
request.user = self.local_user
|
||||
with patch('bookwyrm.views.is_api_request') as is_api:
|
||||
with patch('bookwyrm.views.status.is_api_request') as is_api:
|
||||
is_api.return_value = False
|
||||
result = view(request, 'mouse', status.id)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
self.assertEqual(result.template_name, 'status.html')
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
with patch('bookwyrm.views.is_api_request') as is_api:
|
||||
with patch('bookwyrm.views.status.is_api_request') as is_api:
|
||||
is_api.return_value = True
|
||||
result = view(request, 'mouse', status.id)
|
||||
self.assertIsInstance(result, ActivitypubResponse)
|
||||
|
@ -71,7 +71,7 @@ class StatusViews(TestCase):
|
|||
self.assertEqual(result.template_name, 'status.html')
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
with patch('bookwyrm.views.is_api_request') as is_api:
|
||||
with patch('bookwyrm.views.status.is_api_request') as is_api:
|
||||
is_api.return_value = True
|
||||
result = view(request, 'mouse', status.id)
|
||||
self.assertIsInstance(result, ActivitypubResponse)
|
||||
|
@ -257,3 +257,17 @@ class StatusViews(TestCase):
|
|||
result,
|
||||
'<p><em>hi</em> and <a href="http://fish.com">fish.com</a> ' \
|
||||
'is rad</p>')
|
||||
|
||||
|
||||
def test_handle_delete_status(self):
|
||||
''' marks a status as deleted '''
|
||||
view = views.DeleteStatus.as_view()
|
||||
status = models.Status.objects.create(
|
||||
user=self.local_user, content='hi')
|
||||
self.assertFalse(status.deleted)
|
||||
request = self.factory.post('')
|
||||
request.user = self.local_user
|
||||
with patch('bookwyrm.broadcast.broadcast_task.delay'):
|
||||
view(request, status.id)
|
||||
status.refresh_from_db()
|
||||
self.assertTrue(status.deleted)
|
||||
|
|
Loading…
Reference in a new issue