33
33
NON_OBJECT_ARGS = [list (), tuple (), dict (), 'foo' , 0 , 1 , True , False ]
34
34
NON_LIST_ARGS = ['' , tuple (), dict (), True , False , 1 , 0 , [1 ], ['foo' , 1 ]]
35
35
NON_UINT_ARGS = ['1.23s' , list (), tuple (), dict (), - 1.23 ]
36
+ NON_BOOL_ARGS = ['' , list (), tuple (), dict (), 1 , 0 , [1 ], ['foo' , 1 ], {1 : 'foo' }, {'foo' : 1 }]
36
37
HTTP_ERROR_CODES = {
37
38
400 : exceptions .InvalidArgumentError ,
38
39
403 : exceptions .PermissionDeniedError ,
@@ -249,7 +250,7 @@ def test_fcm_options(self):
249
250
topic = 'topic' ,
250
251
fcm_options = messaging .FCMOptions ('message-label' ),
251
252
android = messaging .AndroidConfig (
252
- fcm_options = messaging .AndroidFCMOptions ('android-label' )),
253
+ fcm_options = messaging .AndroidFCMOptions ('android-label' , False )),
253
254
apns = messaging .APNSConfig (fcm_options =
254
255
messaging .APNSFCMOptions (
255
256
analytics_label = 'apns-label' ,
@@ -259,7 +260,8 @@ def test_fcm_options(self):
259
260
{
260
261
'topic' : 'topic' ,
261
262
'fcm_options' : {'analytics_label' : 'message-label' },
262
- 'android' : {'fcm_options' : {'analytics_label' : 'android-label' }},
263
+ 'android' : {'fcm_options' : {'analytics_label' : 'android-label' ,
264
+ 'direct_boot_ok' : False ,}},
263
265
'apns' : {'fcm_options' : {'analytics_label' : 'apns-label' ,
264
266
'image' : 'https://images.unsplash.com/photo-14944386399'
265
267
'46-1ebd1d20bf85?fit=crop&w=900&q=60' }},
@@ -317,6 +319,21 @@ def test_invalid_data(self, data):
317
319
check_encoding (messaging .Message (
318
320
topic = 'topic' , android = messaging .AndroidConfig (data = data )))
319
321
322
+ @pytest .mark .parametrize ('data' , NON_STRING_ARGS )
323
+ def test_invalid_analytics_label (self , data ):
324
+ with pytest .raises (ValueError ):
325
+ check_encoding (messaging .Message (
326
+ topic = 'topic' , android = messaging .AndroidConfig (
327
+ fcm_options = messaging .AndroidFCMOptions (analytics_label = data ))))
328
+
329
+ @pytest .mark .parametrize ('data' , NON_BOOL_ARGS )
330
+ def test_invalid_direct_boot_ok (self , data ):
331
+ with pytest .raises (ValueError ):
332
+ check_encoding (messaging .Message (
333
+ topic = 'topic' , android = messaging .AndroidConfig (
334
+ fcm_options = messaging .AndroidFCMOptions (direct_boot_ok = data ))))
335
+
336
+
320
337
def test_android_config (self ):
321
338
msg = messaging .Message (
322
339
topic = 'topic' ,
@@ -326,7 +343,7 @@ def test_android_config(self):
326
343
priority = 'high' ,
327
344
ttl = 123 ,
328
345
data = {'k1' : 'v1' , 'k2' : 'v2' },
329
- fcm_options = messaging .AndroidFCMOptions ('analytics_label_v1' )
346
+ fcm_options = messaging .AndroidFCMOptions ('analytics_label_v1' , True )
330
347
)
331
348
)
332
349
expected = {
@@ -342,6 +359,7 @@ def test_android_config(self):
342
359
},
343
360
'fcm_options' : {
344
361
'analytics_label' : 'analytics_label_v1' ,
362
+ 'direct_boot_ok' : True ,
345
363
},
346
364
},
347
365
}
0 commit comments