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,8 @@ 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' ),
254
+ direct_boot_ok = False ),
253
255
apns = messaging .APNSConfig (fcm_options =
254
256
messaging .APNSFCMOptions (
255
257
analytics_label = 'apns-label' ,
@@ -259,7 +261,8 @@ def test_fcm_options(self):
259
261
{
260
262
'topic' : 'topic' ,
261
263
'fcm_options' : {'analytics_label' : 'message-label' },
262
- 'android' : {'fcm_options' : {'analytics_label' : 'android-label' }},
264
+ 'android' : {'fcm_options' : {'analytics_label' : 'android-label' },
265
+ 'direct_boot_ok' : False },
263
266
'apns' : {'fcm_options' : {'analytics_label' : 'apns-label' ,
264
267
'image' : 'https://images.unsplash.com/photo-14944386399'
265
268
'46-1ebd1d20bf85?fit=crop&w=900&q=60' }},
@@ -317,6 +320,20 @@ def test_invalid_data(self, data):
317
320
check_encoding (messaging .Message (
318
321
topic = 'topic' , android = messaging .AndroidConfig (data = data )))
319
322
323
+ @pytest .mark .parametrize ('data' , NON_STRING_ARGS )
324
+ def test_invalid_analytics_label (self , data ):
325
+ with pytest .raises (ValueError ):
326
+ check_encoding (messaging .Message (
327
+ topic = 'topic' , android = messaging .AndroidConfig (
328
+ fcm_options = messaging .AndroidFCMOptions (analytics_label = data ))))
329
+
330
+ @pytest .mark .parametrize ('data' , NON_BOOL_ARGS )
331
+ def test_invalid_direct_boot_ok (self , data ):
332
+ with pytest .raises (ValueError ):
333
+ check_encoding (messaging .Message (
334
+ topic = 'topic' , android = messaging .AndroidConfig (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,8 @@ 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' ),
347
+ direct_boot_ok = True ,
330
348
)
331
349
)
332
350
expected = {
@@ -343,6 +361,7 @@ def test_android_config(self):
343
361
'fcm_options' : {
344
362
'analytics_label' : 'analytics_label_v1' ,
345
363
},
364
+ 'direct_boot_ok' : True ,
346
365
},
347
366
}
348
367
check_encoding (msg , expected )
0 commit comments