feat: replace email flows with in-app notifications
Add recipient notification detail and filtering, a queued admin composer, and contextual automatic titles. Retire email delivery, obsolete auth routes, newsletter data, and related templates and settings.
This commit is contained in:
32
apps/communications/tests/test_announcements.py
Normal file
32
apps/communications/tests/test_announcements.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import json
|
||||
from unittest import mock
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.communications.models import Announcement
|
||||
from apps.users.models import User
|
||||
from core.authentication import create_jwt_token
|
||||
|
||||
|
||||
class AnnouncementDeliveryTests(TestCase):
|
||||
def setUp(self):
|
||||
self.staff = User.objects.create_user(
|
||||
username="announcement_staff", mobile="09193000001", password="password", is_staff=True,
|
||||
)
|
||||
self.auth = {"HTTP_AUTHORIZATION": f"Bearer {create_jwt_token(self.staff)}"}
|
||||
|
||||
@mock.patch("apps.notifications.services.notify_user")
|
||||
def test_publishing_announcement_does_not_send_manual_notifications(self, notify_user):
|
||||
response = self.client.post("/api/communications/announcements/", json.dumps({
|
||||
"title": "News", "content": "# Story", "is_published": True,
|
||||
}), content_type="application/json", **self.auth)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTrue(Announcement.objects.filter(title="News").exists())
|
||||
notify_user.assert_not_called()
|
||||
|
||||
def test_newsletter_category_and_routes_are_removed(self):
|
||||
response = self.client.post("/api/communications/announcements/", json.dumps({
|
||||
"title": "News", "content": "Story", "announcement_type": "newsletter",
|
||||
}), content_type="application/json", **self.auth)
|
||||
self.assertEqual(response.status_code, 422)
|
||||
self.assertEqual(self.client.post("/api/communications/newsletter/subscribe/").status_code, 404)
|
||||
Reference in New Issue
Block a user