Updates tests for inbox tweaks

This commit is contained in:
Mouse Reeve 2021-03-07 09:45:02 -08:00
parent 09b77e567f
commit 47cf77145d
2 changed files with 17 additions and 2 deletions

View file

@ -20,7 +20,7 @@ class Favorite(ActivityMixin, BookWyrmModel):
@classmethod
def ignore_activity(cls, activity):
''' don't bother with incoming favs of unknown statuses '''
return cls.objects.filter(remote_id=activity.object).exists()
return not cls.objects.filter(remote_id=activity.object).exists()
def save(self, *args, **kwargs):
''' update user active time '''

View file

@ -74,7 +74,7 @@ class Inbox(TestCase):
mock_valid.return_value = False
result = self.client.post(
'/user/mouse/inbox',
'{"type": "Test", "object": "exists"}',
'{"type": "Announce", "object": "exists"}',
content_type="application/json"
)
self.assertEqual(result.status_code, 401)
@ -494,6 +494,21 @@ class Inbox(TestCase):
self.assertEqual(fav.remote_id, 'https://example.com/fav/1')
self.assertEqual(fav.user, self.remote_user)
def test_ignore_favorite(self):
''' don't try to save an unknown status '''
activity = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'https://example.com/fav/1',
'actor': 'https://example.com/users/rat',
'type': 'Like',
'published': 'Mon, 25 May 2020 19:31:20 GMT',
'object': 'https://unknown.status/not-found',
}
views.inbox.activity_task(activity)
self.assertFalse(models.Favorite.objects.exists())
def test_handle_unfavorite(self):
''' fav a status '''
activity = {