subject -> topic: Fix push notification tests.

We also make the topic name more clear.
This commit is contained in:
Steve Howell 2018-11-10 15:48:13 +00:00 committed by Tim Abbott
parent 8e639543fb
commit 710095920f
1 changed files with 9 additions and 6 deletions

View File

@ -307,15 +307,18 @@ class PushNotificationTest(BouncerTestCase):
type=type, type=type,
) )
return Message.objects.create( message = Message(
sender=self.sender, sender=self.sender,
recipient=recipient, recipient=recipient,
subject='Test Message',
content='This is test content', content='This is test content',
rendered_content='This is test content', rendered_content='This is test content',
pub_date=now(), pub_date=now(),
sending_client=self.sending_client, sending_client=self.sending_client,
) )
message.set_topic_name('Test Topic')
message.save()
return message
@contextmanager @contextmanager
def mock_apns(self) -> mock.MagicMock: def mock_apns(self) -> mock.MagicMock:
@ -809,7 +812,7 @@ class TestGetAPNsPayload(PushNotificationTest):
payload = apn.get_apns_payload(user_profile, message) payload = apn.get_apns_payload(user_profile, message)
expected = { expected = {
'alert': { 'alert': {
'title': '#Verona > Test Message', 'title': '#Verona > Test Topic',
'subtitle': 'King Hamlet:', 'subtitle': 'King Hamlet:',
'body': message.content, 'body': message.content,
}, },
@ -841,7 +844,7 @@ class TestGetAPNsPayload(PushNotificationTest):
payload = apn.get_apns_payload(user_profile, message) payload = apn.get_apns_payload(user_profile, message)
expected = { expected = {
'alert': { 'alert': {
'title': '#Verona > Test Message', 'title': '#Verona > Test Topic',
'subtitle': 'King Hamlet mentioned you:', 'subtitle': 'King Hamlet mentioned you:',
'body': message.content, 'body': message.content,
}, },
@ -976,7 +979,7 @@ class TestGetGCMPayload(PushNotificationTest):
"sender_full_name": "King Hamlet", "sender_full_name": "King Hamlet",
"sender_avatar_url": apn.absolute_avatar_url(message.sender), "sender_avatar_url": apn.absolute_avatar_url(message.sender),
"recipient_type": "stream", "recipient_type": "stream",
"topic": "Test Message", "topic": "Test Topic",
"stream": "Denmark" "stream": "Denmark"
} }
self.assertDictEqual(payload, expected) self.assertDictEqual(payload, expected)
@ -1004,7 +1007,7 @@ class TestGetGCMPayload(PushNotificationTest):
"sender_full_name": "King Hamlet", "sender_full_name": "King Hamlet",
"sender_avatar_url": apn.absolute_avatar_url(message.sender), "sender_avatar_url": apn.absolute_avatar_url(message.sender),
"recipient_type": "stream", "recipient_type": "stream",
"topic": "Test Message", "topic": "Test Topic",
"stream": "Denmark" "stream": "Denmark"
} }
self.assertDictEqual(payload, expected) self.assertDictEqual(payload, expected)