3333NON_OBJECT_ARGS = [list (), tuple (), dict (), 'foo' , 0 , 1 , True , False ]
3434NON_LIST_ARGS = ['' , tuple (), dict (), True , False , 1 , 0 , [1 ], ['foo' , 1 ]]
3535NON_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 }]
3637HTTP_ERROR_CODES = {
3738 400 : exceptions .InvalidArgumentError ,
3839 403 : exceptions .PermissionDeniedError ,
@@ -249,7 +250,7 @@ def test_fcm_options(self):
249250 topic = 'topic' ,
250251 fcm_options = messaging .FCMOptions ('message-label' ),
251252 android = messaging .AndroidConfig (
252- fcm_options = messaging .AndroidFCMOptions ('android-label' )),
253+ fcm_options = messaging .AndroidFCMOptions ('android-label' , False )),
253254 apns = messaging .APNSConfig (fcm_options =
254255 messaging .APNSFCMOptions (
255256 analytics_label = 'apns-label' ,
@@ -259,7 +260,8 @@ def test_fcm_options(self):
259260 {
260261 'topic' : 'topic' ,
261262 '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 ,}},
263265 'apns' : {'fcm_options' : {'analytics_label' : 'apns-label' ,
264266 'image' : 'https://images.unsplash.com/photo-14944386399'
265267 '46-1ebd1d20bf85?fit=crop&w=900&q=60' }},
@@ -317,6 +319,21 @@ def test_invalid_data(self, data):
317319 check_encoding (messaging .Message (
318320 topic = 'topic' , android = messaging .AndroidConfig (data = data )))
319321
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+
320337 def test_android_config (self ):
321338 msg = messaging .Message (
322339 topic = 'topic' ,
@@ -326,7 +343,7 @@ def test_android_config(self):
326343 priority = 'high' ,
327344 ttl = 123 ,
328345 data = {'k1' : 'v1' , 'k2' : 'v2' },
329- fcm_options = messaging .AndroidFCMOptions ('analytics_label_v1' )
346+ fcm_options = messaging .AndroidFCMOptions ('analytics_label_v1' , True )
330347 )
331348 )
332349 expected = {
@@ -342,6 +359,7 @@ def test_android_config(self):
342359 },
343360 'fcm_options' : {
344361 'analytics_label' : 'analytics_label_v1' ,
362+ 'direct_boot_ok' : True ,
345363 },
346364 },
347365 }
0 commit comments