Notifications: unsubscribe from extension approval activity (#177) #207
50
reviewers/tests/test_notifications.py
Normal file
50
reviewers/tests/test_notifications.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from common.tests.factories.extensions import create_version
|
||||||
|
from common.tests.factories.users import UserFactory
|
||||||
|
from notifications.models import Notification
|
||||||
|
from reviewers.models import ApprovalActivity
|
||||||
|
|
||||||
|
|
||||||
|
class TestNotifications(TestCase):
|
||||||
|
def test_unsubscribe(self):
|
||||||
|
version = create_version()
|
||||||
|
extension = version.extension
|
||||||
|
some_user = UserFactory()
|
||||||
|
some_user2 = UserFactory()
|
||||||
|
|
||||||
|
self.client.force_login(some_user)
|
||||||
|
url = reverse('reviewers:approval-comment', args=[extension.slug])
|
||||||
|
self.client.post(url, {'type': ApprovalActivity.ActivityType.COMMENT, 'message': 'lala'})
|
||||||
|
|
||||||
|
notification_nr = Notification.objects.filter(recipient=some_user).count()
|
||||||
|
self.client.force_login(some_user2)
|
||||||
|
url = reverse('reviewers:approval-comment', args=[extension.slug])
|
||||||
|
self.client.post(url, {'type': ApprovalActivity.ActivityType.COMMENT, 'message': 'lala2'})
|
||||||
|
new_notification_nr = Notification.objects.filter(recipient=some_user).count()
|
||||||
|
self.assertEqual(new_notification_nr, notification_nr + 1)
|
||||||
|
|
||||||
|
# unsubscribe and see what happens
|
||||||
|
self.client.force_login(some_user)
|
||||||
|
url = reverse('reviewers:approval-follow', args=[extension.slug])
|
||||||
|
self.client.post(url, {'follow': ''})
|
||||||
|
|
||||||
|
self.client.force_login(some_user2)
|
||||||
|
url = reverse('reviewers:approval-comment', args=[extension.slug])
|
||||||
|
self.client.post(url, {'type': ApprovalActivity.ActivityType.COMMENT, 'message': 'lala3'})
|
||||||
|
|
||||||
|
new_notification_nr2 = Notification.objects.filter(recipient=some_user).count()
|
||||||
|
self.assertEqual(new_notification_nr2, new_notification_nr)
|
||||||
|
|
||||||
|
# subscribe back
|
||||||
|
self.client.force_login(some_user)
|
||||||
|
url = reverse('reviewers:approval-follow', args=[extension.slug])
|
||||||
|
self.client.post(url, {'follow': '1'})
|
||||||
|
|
||||||
|
self.client.force_login(some_user2)
|
||||||
|
url = reverse('reviewers:approval-comment', args=[extension.slug])
|
||||||
|
self.client.post(url, {'type': ApprovalActivity.ActivityType.COMMENT, 'message': 'lala4'})
|
||||||
|
|
||||||
|
new_notification_nr3 = Notification.objects.filter(recipient=some_user).count()
|
||||||
|
self.assertEqual(new_notification_nr3, new_notification_nr2 + 1)
|
Loading…
Reference in New Issue
Block a user