File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 44https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html
55"""
66
7+ import codecs
78import json
89import ssl
910import struct
@@ -231,5 +232,5 @@ def apns_fetch_inactive_ids():
231232 # Maybe we should have a flag to return the timestamp?
232233 # It doesn't seem that useful right now, though.
233234 for tStamp , registration_id in _apns_receive_feedback (socket ):
234- inactive_ids .append (registration_id .encode ('hex ' ))
235+ inactive_ids .append (codecs .encode (registration_id , 'hex_codec ' ))
235236 return inactive_ids
Original file line number Diff line number Diff line change 11from test_models import *
22from test_gcm_push_payload import *
33from test_apns_push_payload import *
4+ from test_management_commands import *
Original file line number Diff line number Diff line change 1+ import mock
2+
3+ from django .core .management import call_command
4+
5+ from django .test import TestCase
6+ from push_notifications .apns import _apns_send , APNSDataOverflow
7+
8+
9+ class CommandsTestCase (TestCase ):
10+
11+ def test_prune_devices (self ):
12+ from push_notifications .models import APNSDevice
13+
14+ device = APNSDevice .objects .create (
15+ registration_id = "616263" , # hex encoding of b'abc'
16+ )
17+ with mock .patch (
18+ 'push_notifications.apns._apns_create_socket_to_feedback' ,
19+ mock .MagicMock ()):
20+ with mock .patch ('push_notifications.apns._apns_receive_feedback' ,
21+ mock .MagicMock ()) as receiver :
22+ receiver .side_effect = lambda s : [(b'' , b'abc' )]
23+ call_command ('prune_devices' )
24+ device = APNSDevice .objects .get (pk = device .pk )
25+ self .assertFalse (device .active )
You can’t perform that action at this time.
0 commit comments