Skip to content

Commit

Permalink
Attempt to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
James Bligh committed Sep 30, 2023
1 parent a37d1f8 commit df6998f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/test_legacy_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest import mock

from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase

Expand Down
10 changes: 5 additions & 5 deletions tests/test_rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class APNSDeviceSerializerTestCase(TestCase):
def test_validation(self):
# valid data - 32 bytes upper case
# valid data - 64 bytes upper case
serializer = APNSDeviceSerializer(data={
"registration_id": "AEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAE",
"name": "Apple iPhone 6+",
Expand All @@ -20,7 +20,7 @@ def test_validation(self):
})
self.assertTrue(serializer.is_valid())

# valid data - 32 bytes lower case
# valid data - 64 bytes lower case
serializer = APNSDeviceSerializer(data={
"registration_id": "aeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeaeae",
"name": "Apple iPhone 6+",
Expand All @@ -31,23 +31,23 @@ def test_validation(self):

# valid data - 100 bytes upper case
serializer = APNSDeviceSerializer(data={
"registration_id": "AE" * 100,
"registration_id": "AE" * 50,
"name": "Apple iPhone 6+",
"device_id": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
})
self.assertTrue(serializer.is_valid())

# valid data - 100 bytes lower case
serializer = APNSDeviceSerializer(data={
"registration_id": "ae" * 100,
"registration_id": "ae" * 50,
"name": "Apple iPhone 6+",
"device_id": "ffffffffffffffffffffffffffffffff",
})
self.assertTrue(serializer.is_valid())

# valid data - 200 bytes mixed case
serializer = APNSDeviceSerializer(data={
"registration_id": "aE" * 200,
"registration_id": "aE" * 100,
"name": "Apple iPhone 6+",
"device_id": "ffffffffffffffffffffffffffffffff",
})
Expand Down
3 changes: 2 additions & 1 deletion tests/test_webpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.test import TestCase
from pywebpush import WebPushException

from push_notifications.exceptions import WebPushError
from push_notifications.webpush import (
get_subscription_info, webpush_send_message
)
Expand Down Expand Up @@ -88,5 +89,5 @@ def test_webpush_send_message_404(self, webpush_mock):
"push_notifications.webpush.webpush",
side_effect=WebPushException("Error"))
def test_webpush_send_message_exception(self, webpush_mock):
with self.assertRaises(WebPushException):
with self.assertRaises(WebPushError):
webpush_send_message(self.mock_device, "message")

0 comments on commit df6998f

Please sign in to comment.