Skip to content

Commit 3e88551

Browse files
committed
Add FCM push type and remove MPNS support due to its end of life
1 parent f5be446 commit 3e88551

16 files changed

+66
-282
lines changed

pubnub/enums.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ class PNReconnectionPolicy(object):
143143

144144
class PNPushType(object):
145145
APNS = 1
146-
MPNS = 2
147-
GCM = 3
146+
GCM = 3 # Deprecated: Use FCM instead. GCM has been replaced by FCM (Firebase Cloud Messaging)
148147
APNS2 = 4
148+
FCM = 5
149149

150150

151151
class PNResourceType(object):

pubnub/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def push_type_to_string(push_type):
154154
return "apns"
155155
elif push_type == PNPushType.GCM:
156156
return "gcm"
157-
elif push_type == PNPushType.MPNS:
158-
return "mpns"
157+
elif push_type == PNPushType.FCM:
158+
return "fcm"
159159
else:
160160
return ""
161161

tests/functional/push/test_add_channels_to_push.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,30 @@ def test_push_add_single_channel(self):
4343
self.assertEqual(self.add_channels._channels, ['ch'])
4444

4545
def test_push_add_multiple_channels(self):
46-
self.add_channels.channels(['ch1', 'ch2']).push_type(pubnub.enums.PNPushType.MPNS).device_id("coolDevice")
46+
self.add_channels.channels(['ch1', 'ch2']).push_type(pubnub.enums.PNPushType.APNS).device_id("coolDevice")
4747

4848
params = (pnconf.subscribe_key, "coolDevice")
4949
self.assertEqual(self.add_channels.build_path(), AddChannelsToPush.ADD_PATH % params)
5050

5151
self.assertEqual(self.add_channels.build_params_callback()({}), {
5252
'pnsdk': sdk_name,
5353
'uuid': self.pubnub.uuid,
54-
'type': 'mpns',
54+
'type': 'apns',
5555
'add': 'ch1,ch2'
5656
})
5757

5858
self.assertEqual(self.add_channels._channels, ['ch1', 'ch2'])
5959

6060
def test_push_add_google(self):
61-
self.add_channels.channels(['ch1', 'ch2', 'ch3']).push_type(pubnub.enums.PNPushType.GCM).device_id("coolDevice")
61+
self.add_channels.channels(['ch1', 'ch2', 'ch3']).push_type(pubnub.enums.PNPushType.FCM).device_id("coolDevice")
6262

6363
params = (pnconf.subscribe_key, "coolDevice")
6464
self.assertEqual(self.add_channels.build_path(), AddChannelsToPush.ADD_PATH % params)
6565

6666
self.assertEqual(self.add_channels.build_params_callback()({}), {
6767
'pnsdk': sdk_name,
6868
'uuid': self.pubnub.uuid,
69-
'type': 'gcm',
69+
'type': 'fcm',
7070
'add': 'ch1,ch2,ch3'
7171
})
7272

tests/functional/push/test_list_push_provisions.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ def test_list_channel_group_gcm(self):
5555
'type': 'gcm'
5656
})
5757

58-
def test_list_channel_group_mpns(self):
59-
self.list_push.push_type(PNPushType.MPNS).device_id('coolDevice')
60-
61-
self.assertEqual(self.list_push.build_path(),
62-
ListPushProvisions.LIST_PATH % (
63-
pnconf.subscribe_key, "coolDevice"))
64-
65-
self.assertEqual(self.list_push.build_params_callback()({}), {
66-
'pnsdk': sdk_name,
67-
'uuid': self.pubnub.uuid,
68-
'type': 'mpns'
69-
})
70-
7158
def test_list_channel_group_apns2(self):
7259
self.list_push.push_type(PNPushType.APNS2).device_id('coolDevice')\
7360
.environment(pubnub.enums.PNPushEnvironment.PRODUCTION).topic("testTopic")

tests/functional/push/test_remove_channels_from_push.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ def test_push_remove_single_channel(self):
3636
self.assertEqual(self.remove_channels._channels, ['ch'])
3737

3838
def test_push_remove_multiple_channels(self):
39-
self.remove_channels.channels(['ch1', 'ch2']).push_type(pubnub.enums.PNPushType.MPNS).device_id("coolDevice")
39+
self.remove_channels.channels(['ch1', 'ch2']).push_type(pubnub.enums.PNPushType.APNS).device_id("coolDevice")
4040

4141
params = (pnconf.subscribe_key, "coolDevice")
4242
self.assertEqual(self.remove_channels.build_path(), RemoveChannelsFromPush.REMOVE_PATH % params)
4343

4444
self.assertEqual(self.remove_channels.build_params_callback()({}), {
4545
'pnsdk': sdk_name,
4646
'uuid': self.pubnub.uuid,
47-
'type': 'mpns',
47+
'type': 'apns',
4848
'remove': 'ch1,ch2'
4949
})
5050

5151
self.assertEqual(self.remove_channels._channels, ['ch1', 'ch2'])
5252

5353
def test_push_remove_google(self):
54-
self.remove_channels.channels(['ch1', 'ch2', 'ch3']).push_type(pubnub.enums.PNPushType.GCM)\
54+
self.remove_channels.channels(['ch1', 'ch2', 'ch3']).push_type(pubnub.enums.PNPushType.FCM)\
5555
.device_id("coolDevice")
5656

5757
params = (pnconf.subscribe_key, "coolDevice")
@@ -60,7 +60,7 @@ def test_push_remove_google(self):
6060
self.assertEqual(self.remove_channels.build_params_callback()({}), {
6161
'pnsdk': sdk_name,
6262
'uuid': self.pubnub.uuid,
63-
'type': 'gcm',
63+
'type': 'fcm',
6464
'remove': 'ch1,ch2,ch3'
6565
})
6666

tests/functional/push/test_remove_device_from_push.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ def test_remove_push_gcm(self):
5050
'type': 'gcm',
5151
})
5252

53-
def test_remove_push_mpns(self):
54-
self.remove_device.push_type(pubnub.enums.PNPushType.MPNS).device_id("coolDevice")
53+
def test_remove_push_fcm(self):
54+
self.remove_device.push_type(pubnub.enums.PNPushType.FCM).device_id("coolDevice")
5555

5656
params = (pnconf.subscribe_key, "coolDevice")
5757
self.assertEqual(self.remove_device.build_path(), RemoveDeviceFromPush.REMOVE_PATH % params)
5858

5959
self.assertEqual(self.remove_device.build_params_callback()({}), {
6060
'pnsdk': sdk_name,
6161
'uuid': self.pubnub.uuid,
62-
'type': 'mpns',
62+
'type': 'fcm',
6363
})
6464

6565
def test_remove_push_apns2(self):

tests/integrational/fixtures/native_sync/list_push_channels/mpns_basic_success.json

Lines changed: 0 additions & 64 deletions
This file was deleted.

tests/integrational/fixtures/native_sync/remove_channels_from_push/mpns_basic_success.json

Lines changed: 0 additions & 64 deletions
This file was deleted.

tests/integrational/fixtures/native_sync/remove_device_from_push/mpns_basic_success.json

Lines changed: 0 additions & 64 deletions
This file was deleted.

tests/integrational/native_sync/test_list_push_channels.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,6 @@ def test_list_push_channels_apns2_basic_success(self):
8282
self.assertTrue(envelope.status.is_error() is False)
8383
self.assertIsInstance(envelope.result.channels, list)
8484

85-
@pn_vcr.use_cassette(
86-
'tests/integrational/fixtures/native_sync/list_push_channels/mpns_basic_success.json',
87-
serializer='pn_json',
88-
filter_query_parameters=['seqn', 'pnsdk', 'l_sig']
89-
)
90-
def test_list_push_channels_mpns_basic_success(self):
91-
"""Test basic MPNS channel listing functionality."""
92-
device_id = "0000000000000000"
93-
94-
envelope = self.pubnub.list_push_channels() \
95-
.device_id(device_id) \
96-
.push_type(PNPushType.MPNS) \
97-
.sync()
98-
99-
self.assertIsNotNone(envelope)
100-
self.assertIsNotNone(envelope.result)
101-
self.assertTrue(envelope.status.is_error() is False)
102-
self.assertIsInstance(envelope.result.channels, list)
103-
10485
@pn_vcr.use_cassette(
10586
'tests/integrational/fixtures/native_sync/list_push_channels/empty_device.json',
10687
serializer='pn_json',

0 commit comments

Comments
 (0)