本文整理汇总了Python中interface.services.dm.iuser_notification_service.UserNotificationServiceClient.create_email方法的典型用法代码示例。如果您正苦于以下问题:Python UserNotificationServiceClient.create_email方法的具体用法?Python UserNotificationServiceClient.create_email怎么用?Python UserNotificationServiceClient.create_email使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.dm.iuser_notification_service.UserNotificationServiceClient
的用法示例。
在下文中一共展示了UserNotificationServiceClient.create_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserNotificationIntTest
# 需要导入模块: from interface.services.dm.iuser_notification_service import UserNotificationServiceClient [as 别名]
# 或者: from interface.services.dm.iuser_notification_service.UserNotificationServiceClient import create_email [as 别名]
class UserNotificationIntTest(IonIntegrationTestCase):
def setUp(self):
self._start_container()
self.container.start_rel_from_url('res/deploy/r2dm.yml')
self.unsc = UserNotificationServiceClient(node=self.container.node)
self.rrc = ResourceRegistryServiceClient(node=self.container.node)
self.imc = IdentityManagementServiceClient(node=self.container.node)
@attr('LOCOINT')
@unittest.skipIf(os.getenv('CEI_LAUNCH_TEST', False), 'Skip test while in CEI LAUNCH mode')
def test_email(self):
proc1 = self.container.proc_manager.procs_by_name['user_notification']
# Create a user and get the user_id
user = UserInfo(name = 'new_user')
user_id, _ = self.rrc.create(user)
# set up....
notification_id = self.unsc.create_email(event_type='ResourceLifecycleEvent',
event_subtype=None,
origin='Some_Resource_Agent_ID1',
origin_type=None,
user_id=user_id,
email='[email protected]',
mode = DeliveryMode.DIGEST,
message_header='message_header',
parser='parser',
period=1)
#------------------------------------------------------------------------------------------------------
# Setup so as to be able to get the message and headers going into the
# subscription callback method of the EmailEventProcessor
#------------------------------------------------------------------------------------------------------
# publish an event for each notification to generate the emails
rle_publisher = EventPublisher("ResourceLifecycleEvent")
rle_publisher.publish_event(origin='Some_Resource_Agent_ID1', description="RLE test event")
msg_tuple = proc1.event_processors[notification_id].smtp_client.sentmail.get(timeout=4)
self.assertTrue(proc1.event_processors[notification_id].smtp_client.sentmail.empty())
message = msg_tuple[2]
list_lines = message.split("\n")
#-------------------------------------------------------
# parse the message body
#-------------------------------------------------------
message_dict = {}
for line in list_lines:
key_item = line.split(": ")
if key_item[0] == 'Subject':
message_dict['Subject'] = key_item[1] + key_item[2]
else:
try:
message_dict[key_item[0]] = key_item[1]
except IndexError as exc:
# these IndexError exceptions happen only because the message sometimes
# has successive /r/n (i.e. new lines) and therefore,
# the indexing goes out of range. These new lines
# can just be ignored. So we ignore the exceptions here.
pass
#-------------------------------------------------------
# make assertions
#-------------------------------------------------------
self.assertEquals(msg_tuple[1], '[email protected]' )
#self.assertEquals(msg_tuple[0], ION_NOTIFICATION_EMAIL_ADDRESS)
#self.assertEquals(message_dict['From'], ION_NOTIFICATION_EMAIL_ADDRESS)
self.assertEquals(message_dict['To'], '[email protected]')
self.assertEquals(message_dict['Event'].rstrip('\r'), 'ResourceLifecycleEvent')
self.assertEquals(message_dict['Originator'].rstrip('\r'), 'Some_Resource_Agent_ID1')
self.assertEquals(message_dict['Description'].rstrip('\r'), 'RLE test event')
@attr('LOCOINT')
@unittest.skipIf(os.getenv('CEI_LAUNCH_TEST', False), 'Skip test while in CEI LAUNCH mode')
def test_sms(self):
proc1 = self.container.proc_manager.procs_by_name['user_notification']
# Create a user and get the user_id
user = UserInfo(name = 'new_user')
user_id, _ = self.rrc.create(user)
# set up....
notification_id = self.unsc.create_sms(event_type='ResourceLifecycleEvent',
event_subtype=None,
origin='Some_Resource_Agent_ID1',
origin_type=None,
user_id=user_id,
phone = '401-XXX-XXXX',
provider='T-Mobile',
message_header='message_header',
parser='parser',
#.........这里部分代码省略.........