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,8 @@ 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' ),
254+ direct_boot_ok = False ),
253255 apns = messaging .APNSConfig (fcm_options =
254256 messaging .APNSFCMOptions (
255257 analytics_label = 'apns-label' ,
@@ -259,7 +261,8 @@ def test_fcm_options(self):
259261 {
260262 'topic' : 'topic' ,
261263 '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 },
263266 'apns' : {'fcm_options' : {'analytics_label' : 'apns-label' ,
264267 'image' : 'https://images.unsplash.com/photo-14944386399'
265268 '46-1ebd1d20bf85?fit=crop&w=900&q=60' }},
@@ -317,6 +320,20 @@ def test_invalid_data(self, data):
317320 check_encoding (messaging .Message (
318321 topic = 'topic' , android = messaging .AndroidConfig (data = data )))
319322
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+
320337 def test_android_config (self ):
321338 msg = messaging .Message (
322339 topic = 'topic' ,
@@ -326,7 +343,8 @@ 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' ),
347+ direct_boot_ok = True ,
330348 )
331349 )
332350 expected = {
@@ -343,6 +361,7 @@ def test_android_config(self):
343361 'fcm_options' : {
344362 'analytics_label' : 'analytics_label_v1' ,
345363 },
364+ 'direct_boot_ok' : True ,
346365 },
347366 }
348367 check_encoding (msg , expected )
0 commit comments