How to use message_icon method in Kiwi

Best Python code snippet using Kiwi_python

fcm.py

Source:fcm.py Github

copy

Full Screen

1from .baseapi import BaseAPI2class FCMNotification(BaseAPI):3 def notify_single_device(self,4 registration_id=None,5 message_body=None,6 message_title=None,7 message_icon=None,8 sound=None,9 condition=None,10 collapse_key=None,11 delay_while_idle=False,12 time_to_live=None,13 restricted_package_name=None,14 low_priority=False,15 dry_run=False,16 data_message=None):17 """18 Send push notification to a single device19 Args:20 registration_id (str): FCM device registration IDs.21 message_body (str): Message string to display in the notification tray22 data_message (dict): Data message payload to send alone or with the notification message23 sound (str): The sound file name to play. Specify "Default" for device default sound.24 Keyword Args:25 collapse_key (str, optional): Identifier for a group of messages26 that can be collapsed so that only the last message gets sent27 when delivery can be resumed. Defaults to ``None``.28 delay_while_idle (bool, optional): If ``True`` indicates that the29 message should not be sent until the device becomes active.30 time_to_live (int, optional): How long (in seconds) the message31 should be kept in FCM storage if the device is offline. The32 maximum time to live supported is 4 weeks. Defaults to ``None``33 which uses the FCM default of 4 weeks.34 low_priority (boolean, optional): Whether to send notification with35 the low priority flag. Defaults to ``False``.36 restricted_package_name (str, optional): Package name of the37 application where the registration IDs must match in order to38 receive the message. Defaults to ``None``.39 dry_run (bool, optional): If ``True`` no message will be sent but40 request will be tested.41 Returns:42 :dict:`multicast_id(long), success(int), failure(int), canonical_ids(int), results(list)`:43 Response from FCM server.44 Raises:45 AuthenticationError: If :attr:`api_key` is not set or provided or there is an error authenticating the sender.46 FCMServerError: Internal server error or timeout error on Firebase cloud messaging server47 InvalidDataError: Invalid data provided48 InternalPackageError: Mostly from changes in the response of FCM, contact the project owner to resolve the issue49 """50 # [registration_id] cos we're sending to a single device51 payload = self.parse_payload(registration_ids=[registration_id],52 message_body=message_body,53 message_title=message_title,54 message_icon=message_icon, 55 sound=sound,56 collapse_key=collapse_key,57 delay_while_idle=delay_while_idle, 58 time_to_live=time_to_live,59 restricted_package_name=restricted_package_name, 60 low_priority=low_priority,61 dry_run=dry_run, data_message=data_message)62 return self.send_request([payload])63 def notify_multiple_devices(self,64 registration_ids=None,65 message_body=None,66 message_title=None,67 message_icon=None,68 sound=None,69 condition=None,70 collapse_key=None,71 delay_while_idle=False,72 time_to_live=None,73 restricted_package_name=None,74 low_priority=False,75 dry_run=False,76 data_message=None):77 """78 Sends push notification to multiple devices,79 can send to over 1000 devices80 Args:81 registration_ids (list): FCM device registration IDs.82 message_body (str): Message string to display in the notification tray83 data_message (dict): Data message payload to send alone or with the notification message84 sound (str): The sound file name to play. Specify "Default" for device default sound.85 Keyword Args:86 collapse_key (str, optional): Identifier for a group of messages87 that can be collapsed so that only the last message gets sent88 when delivery can be resumed. Defaults to ``None``.89 delay_while_idle (bool, optional): If ``True`` indicates that the90 message should not be sent until the device becomes active.91 time_to_live (int, optional): How long (in seconds) the message92 should be kept in FCM storage if the device is offline. The93 maximum time to live supported is 4 weeks. Defaults to ``None``94 which uses the FCM default of 4 weeks.95 low_priority (boolean, optional): Whether to send notification with96 the low priority flag. Defaults to ``False``.97 restricted_package_name (str, optional): Package name of the98 application where the registration IDs must match in order to99 receive the message. Defaults to ``None``.100 dry_run (bool, optional): If ``True`` no message will be sent but101 request will be tested.102 Returns:103 :tuple:`multicast_id(long), success(int), failure(int), canonical_ids(int), results(list)`:104 Response from FCM server.105 Raises:106 AuthenticationError: If :attr:`api_key` is not set or provided or there is an error authenticating the sender.107 FCMServerError: Internal server error or timeout error on Firebase cloud messaging server108 InvalidDataError: Invalid data provided109 InternalPackageError: JSON parsing error, mostly from changes in the response of FCM, create a new github issue to resolve it.110 """111 if len(registration_ids) > self.FCM_MAX_RECIPIENTS:112 payloads = list()113 registration_id_chunks = self.registration_id_chunks(registration_ids)114 for registration_ids in registration_id_chunks:115 # appends a payload with a chunk of registration ids here116 payloads.append(self.parse_payload(registration_ids=registration_ids,117 message_body=message_body,118 message_title=message_title,119 sound=sound,120 message_icon=message_icon, 121 collapse_key=collapse_key,122 delay_while_idle=delay_while_idle, 123 time_to_live=time_to_live,124 restricted_package_name=restricted_package_name,125 low_priority=low_priority,126 dry_run=dry_run, data_message=data_message))127 return self.send_request(payloads)128 else:129 payload = self.parse_payload(registration_ids=registration_ids,130 message_body=message_body,131 message_title=message_title,132 message_icon=message_icon, 133 sound=sound,134 collapse_key=collapse_key,135 delay_while_idle=delay_while_idle, 136 time_to_live=time_to_live,137 restricted_package_name=restricted_package_name, 138 low_priority=low_priority,139 dry_run=dry_run, data_message=data_message)140 return self.send_request([payload])141 def notify_topic_subscribers(self,142 topic_name=None,143 message_body=None,144 message_title=None,145 message_icon=None,146 sound=None,147 condition=None,148 collapse_key=None,149 delay_while_idle=False,150 time_to_live=None,151 restricted_package_name=None,152 low_priority=False,153 dry_run=False,154 data_message=None):155 """156 Sends push notification to multiple devices subscribe to a topic157 Args:158 topic_name (topic_name): Name of the topic to deliver messages to159 A topic name is a string that can be formed with any character in [a-zA-Z0-9-_.~%]160 message_body (str): Message string to display in the notification tray161 data_message (dict): Data message payload to send alone or with the notification message162 sound (str): The sound file name to play. Specify "Default" for device default sound.163 Keyword Args:164 collapse_key (str, optional): Identifier for a group of messages165 that can be collapsed so that only the last message gets sent166 when delivery can be resumed. Defaults to ``None``.167 delay_while_idle (bool, optional): If ``True`` indicates that the168 message should not be sent until the device becomes active.169 time_to_live (int, optional): How long (in seconds) the message170 should be kept in FCM storage if the device is offline. The171 maximum time to live supported is 4 weeks. Defaults to ``None``172 which uses the FCM default of 4 weeks.173 low_priority (boolean, optional): Whether to send notification with174 the low priority flag. Defaults to ``False``.175 restricted_package_name (str, optional): Package name of the176 application where the registration IDs must match in order to177 receive the message. Defaults to ``None``.178 dry_run (bool, optional): If ``True`` no message will be sent but179 request will be tested.180 Returns:181 :tuple:`multicast_id(long), success(int), failure(int), canonical_ids(int), results(list)`:182 Response from FCM server.183 Raises:184 AuthenticationError: If :attr:`api_key` is not set or provided or there is an error authenticating the sender.185 FCMServerError: Internal server error or timeout error on Firebase cloud messaging server186 InvalidDataError: Invalid data provided187 InternalPackageError: JSON parsing error, mostly from changes in the response of FCM, create a new github issue to resolve it.188 """189 payload = self.parse_payload(topic_name=topic_name,190 message_body=message_body,191 message_title=message_title,192 message_icon=message_icon,193 sound=sound, 194 collapse_key=collapse_key,195 delay_while_idle=delay_while_idle, 196 time_to_live=time_to_live,197 restricted_package_name=restricted_package_name, 198 low_priority=low_priority,199 dry_run=dry_run, data_message=data_message)...

Full Screen

Full Screen

tornado.py

Source:tornado.py Github

copy

Full Screen

1from tornado import escape2from tornado import gen3from tornado.httpclient import AsyncHTTPClient, HTTPRequest4from ..baseapi import BaseAPI5from ..errors import AuthenticationError, InternalPackageError, FCMServerError6from ..fcm import FCMNotification7class TornadoBaseAPI(BaseAPI):8 def __init__(self, *args, **kwargs):9 super(TornadoBaseAPI, self).__init__(*args, **kwargs)10 self.http_client = AsyncHTTPClient()11 @gen.coroutine12 def send_request(self, payloads=None):13 for payload in payloads:14 request = HTTPRequest(15 url=self.FCM_END_POINT,16 method='POST',17 headers=self.request_headers(),18 body=payload19 )20 response = yield self.http_client.fetch(request)21 if response.code == 200:22 yield self.parse_response(response)23 return24 elif response.code == 401:25 raise AuthenticationError('There was an error authenticating the sender account')26 elif response.code == 400:27 raise InternalPackageError('Unknown internal error')28 else:29 raise FCMServerError('FCM server is temporarily unavailable')30 def parse_response(self, response):31 if 'content-length' in response.headers and int(response.headers['content-length']) <= 0:32 return {}33 parsed_response = escape.json_decode(response.body)34 multicast_id = parsed_response.get('multicast_id', None)35 success = parsed_response.get('success', 0)36 failure = parsed_response.get('failure', 0)37 canonical_ids = parsed_response.get('canonical_ids', 0)38 results = parsed_response.get('results', [])39 message_id = parsed_response.get('message_id', None) # for topic messages40 if message_id:41 success = 142 return {'multicast_id': multicast_id,43 'success': success,44 'failure': failure,45 'canonical_ids': canonical_ids,46 'results': results}47class TornadoFCMNotification(FCMNotification, TornadoBaseAPI):48 @gen.coroutine49 def notify_single_device(self,50 registration_id=None,51 message_body=None,52 message_title=None,53 message_icon=None,54 sound=None,55 condition=None,56 collapse_key=None,57 delay_while_idle=False,58 time_to_live=None,59 restricted_package_name=None,60 low_priority=False,61 dry_run=False,62 data_message=None,63 click_action=None,64 badge=None,65 color=None,66 tag=None,67 body_loc_key=None,68 body_loc_args=None,69 title_loc_key=None,70 title_loc_args=None):71 # [registration_id] cos we're sending to a single device72 payload = self.parse_payload(registration_ids=[registration_id],73 message_body=message_body,74 message_title=message_title,75 message_icon=message_icon,76 sound=sound,77 collapse_key=collapse_key,78 delay_while_idle=delay_while_idle,79 time_to_live=time_to_live,80 restricted_package_name=restricted_package_name,81 low_priority=low_priority,82 dry_run=dry_run, data_message=data_message, click_action=click_action,83 badge=badge,84 color=color,85 tag=tag,86 body_loc_key=body_loc_key,87 body_loc_args=body_loc_args,88 title_loc_key=title_loc_key,89 title_loc_args=title_loc_args)90 yield self.send_request([payload])91 return92 @gen.coroutine93 def notify_multiple_devices(self,94 registration_ids=None,95 message_body=None,96 message_title=None,97 message_icon=None,98 sound=None,99 condition=None,100 collapse_key=None,101 delay_while_idle=False,102 time_to_live=None,103 restricted_package_name=None,104 low_priority=False,105 dry_run=False,106 data_message=None,107 click_action=None,108 badge=None,109 color=None,110 tag=None,111 body_loc_key=None,112 body_loc_args=None,113 title_loc_key=None,114 title_loc_args=None):115 if len(registration_ids) > self.FCM_MAX_RECIPIENTS:116 payloads = list()117 registration_id_chunks = self.registration_id_chunks(registration_ids)118 for registration_ids in registration_id_chunks:119 # appends a payload with a chunk of registration ids here120 payloads.append(self.parse_payload(registration_ids=registration_ids,121 message_body=message_body,122 message_title=message_title,123 sound=sound,124 message_icon=message_icon,125 collapse_key=collapse_key,126 delay_while_idle=delay_while_idle,127 time_to_live=time_to_live,128 restricted_package_name=restricted_package_name,129 low_priority=low_priority,130 dry_run=dry_run, data_message=data_message,131 click_action=click_action,132 badge=badge,133 color=color,134 tag=tag,135 body_loc_key=body_loc_key,136 body_loc_args=body_loc_args,137 title_loc_key=title_loc_key,138 title_loc_args=title_loc_args))139 yield self.send_request(payloads)140 return141 else:142 payload = self.parse_payload(registration_ids=registration_ids,143 message_body=message_body,144 message_title=message_title,145 message_icon=message_icon,146 sound=sound,147 collapse_key=collapse_key,148 delay_while_idle=delay_while_idle,149 time_to_live=time_to_live,150 restricted_package_name=restricted_package_name,151 low_priority=low_priority,152 dry_run=dry_run, data_message=data_message, click_action=click_action,153 badge=badge,154 color=color,155 tag=tag,156 body_loc_key=body_loc_key,157 body_loc_args=body_loc_args,158 title_loc_key=title_loc_key,159 title_loc_args=title_loc_args)160 yield self.send_request([payload])161 return162 @gen.coroutine163 def notify_topic_subscribers(self,164 topic_name=None,165 message_body=None,166 message_title=None,167 message_icon=None,168 sound=None,169 condition=None,170 collapse_key=None,171 delay_while_idle=False,172 time_to_live=None,173 restricted_package_name=None,174 low_priority=False,175 dry_run=False,176 data_message=None,177 click_action=None,178 badge=None,179 color=None,180 tag=None,181 body_loc_key=None,182 body_loc_args=None,183 title_loc_key=None,184 title_loc_args=None):185 payload = self.parse_payload(topic_name=topic_name,186 message_body=message_body,187 message_title=message_title,188 message_icon=message_icon,189 sound=sound,190 collapse_key=collapse_key,191 delay_while_idle=delay_while_idle,192 time_to_live=time_to_live,193 restricted_package_name=restricted_package_name,194 low_priority=low_priority,195 dry_run=dry_run, data_message=data_message, click_action=click_action,196 badge=badge,197 color=color,198 tag=tag,199 body_loc_key=body_loc_key,200 body_loc_args=body_loc_args,201 title_loc_key=title_loc_key,202 title_loc_args=title_loc_args)203 yield self.send_request([payload])...

Full Screen

Full Screen

test_message_icons.py

Source:test_message_icons.py Github

copy

Full Screen

...3from django.contrib import messages4from django.contrib.messages.storage.base import Message5from tcms.core.templatetags.extra_filters import message_icon6class TestMessageIcons(unittest.TestCase):7 def test_error_message_icon(self):8 self.assertEqual(9 message_icon(Message(messages.ERROR, "error")), "pficon-error-circle-o"10 )11 def test_warning_message_icon(self):12 self.assertEqual(13 message_icon(Message(messages.WARNING, "warning")),14 "pficon-warning-triangle-o",15 )16 def test_success_message_icon(self):17 self.assertEqual(message_icon(Message(messages.SUCCESS, "ok")), "pficon-ok")18 def test_info_message_icon(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful