本文整理汇总了Python中common.utilities.inversion_of_control.Dependency.send_html_email方法的典型用法代码示例。如果您正苦于以下问题:Python Dependency.send_html_email方法的具体用法?Python Dependency.send_html_email怎么用?Python Dependency.send_html_email使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.utilities.inversion_of_control.Dependency
的用法示例。
在下文中一共展示了Dependency.send_html_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRetailMDSMonitor
# 需要导入模块: from common.utilities.inversion_of_control import Dependency [as 别名]
# 或者: from common.utilities.inversion_of_control.Dependency import send_html_email [as 别名]
#.........这里部分代码省略.........
# go!
status = monitor.monitor()
self.assertEqual(status, "failed")
def test_send_error_email(self):
# create monitor
monitor = RetailMDSMonitor()
# create various mocked/expected values
mock_date = "1/1/2012"
error_string = "chicken woot error."
quote = "arnie quote"
hostname = "my_computer"
mock_body = '<br />'.join([
"Error running Retail MDS Monitor",
"",
"Error Timestamp: %s" % mock_date,
"",
"Host: %s" % hostname,
"",
"Error: ",
"",
"",
error_string,
"",
"",
quote])
# stub out various things that the email needs
self.mox.StubOutWithMock(datetime, "datetime")
self.mox.StubOutWithMock(sysadmin_helper, "get_host_name")
self.mox.StubOutWithMock(signal_quote_generator, "get_email_quote")
# begin recording
datetime.datetime.utcnow().AndReturn(mock_date)
sysadmin_helper.get_host_name().AndReturn(hostname)
signal_quote_generator.get_email_quote("<br />").AndReturn(quote)
self.mock_email_provider.send_html_email("[email protected]", ["[email protected]"], "Retail MDS Monitor Error", mock_body)
# replay all
self.mox.ReplayAll()
# go
monitor.send_error_email(error_string)
def test_send_incorrect_server_email(self):
# create monitor
monitor = RetailMDSMonitor()
# create various mocked/expected values
mock_date = "1/1/2012"
database = "blah"
quote = "arnie quote"
hostname = "my_computer"
mock_body = '<br />'.join([
"Retail MDS is pointing at an incorrect database.",
"",
"Timestamp: %s" % mock_date,
"",
"Host: %s" % hostname,
"",
"Database: '%s' did not match regex: '^coredata-us-[a-zA-Z][0-9]:27017'" % database,
"",
"",
quote])
# stub out various things that the email needs
self.mox.StubOutWithMock(datetime, "datetime")
self.mox.StubOutWithMock(sysadmin_helper, "get_host_name")
self.mox.StubOutWithMock(signal_quote_generator, "get_email_quote")
# begin recording
datetime.datetime.utcnow().AndReturn(mock_date)
sysadmin_helper.get_host_name().AndReturn(hostname)
signal_quote_generator.get_email_quote("<br />").AndReturn(quote)
self.mock_email_provider.send_html_email("[email protected]", ["[email protected]"], "Retail MDS Monitor Alert", mock_body)
# replay all
self.mox.ReplayAll()
# go
monitor.send_incorrect_server_email(database)
# ------------------------------ Private Helpers ------------------------------ #
def _get_mock_response_json(self, server_name):
return {
"status": {
"server": server_name
}
}