Add retry-safe scan completion notifications
This commit is contained in:
@@ -5,7 +5,7 @@ from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from .models import UserSettings
|
||||
from .services.notifications import NotificationError, send_notification
|
||||
from .services.notifications import NotificationError, send_notification, send_ntfy_notification
|
||||
|
||||
|
||||
class NtfySettingsTests(TestCase):
|
||||
@@ -47,3 +47,15 @@ class NtfySettingsTests(TestCase):
|
||||
def test_disabled_preference_suppresses_delivery(self, sender):
|
||||
self.assertFalse(send_notification(self.user, 'Title', 'Message'))
|
||||
sender.assert_not_called()
|
||||
|
||||
@patch('planner.services.notifications.urlopen')
|
||||
def test_send_ntfy_notification_includes_stable_sequence_id(self, urlopen):
|
||||
response = Mock()
|
||||
response.getcode.return_value = 200
|
||||
urlopen.return_value.__enter__.return_value = response
|
||||
|
||||
send_ntfy_notification(self.topic, 'Title', 'Message', sequence_id='inventory-scan-123')
|
||||
|
||||
request = urlopen.call_args.args[0]
|
||||
headers = {key.lower(): value for key, value in request.header_items()}
|
||||
self.assertEqual(headers['x-sequence-id'], 'inventory-scan-123')
|
||||
|
||||
Reference in New Issue
Block a user