本文整理匯總了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
}
}