forked from sebasterix/django-push-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support of python3 for prune_devices management command
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from test_models import * | ||
from test_gcm_push_payload import * | ||
from test_apns_push_payload import * | ||
from test_management_commands import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import mock | ||
|
||
from django.core.management import call_command | ||
|
||
from django.test import TestCase | ||
from push_notifications.apns import _apns_send, APNSDataOverflow | ||
|
||
|
||
class CommandsTestCase(TestCase): | ||
|
||
def test_prune_devices(self): | ||
from push_notifications.models import APNSDevice | ||
|
||
device = APNSDevice.objects.create( | ||
registration_id="616263", # hex encoding of b'abc' | ||
) | ||
with mock.patch( | ||
'push_notifications.apns._apns_create_socket_to_feedback', | ||
mock.MagicMock()): | ||
with mock.patch('push_notifications.apns._apns_receive_feedback', | ||
mock.MagicMock()) as receiver: | ||
receiver.side_effect = lambda s: [(b'', b'abc')] | ||
call_command('prune_devices') | ||
device = APNSDevice.objects.get(pk=device.pk) | ||
self.assertFalse(device.active) |