l.t.mail_helpers : module documentation

Part of lp.testing

Helper functions dealing with emails in tests.
Function pop_notifications Return generated emails as email messages.
Function sort_addresses Sort an address-list in an email header field body.
Function print_emails Pop all messages from stub.test_emails and print them with
Function print_distinct_emails A convenient shortcut for `print_emails`(group_similar=True).
Function run_mail_jobs Process job queues that send out emails.
def pop_notifications(sort_key=None, commit=True):
Return generated emails as email messages.

A helper function which optionally commits the transaction, so
that the notifications are queued in stub.test_emails and pops these
notifications from the queue.

:param sort_key: define sorting function.  sort_key specifies a
function of one argument that is used to extract a comparison key from
each list element.  (See the sorted() Python built-in.)
:param commit: whether to commit before reading email (defaults to True).
def sort_addresses(header):
Sort an address-list in an email header field body.
def print_emails(include_reply_to=False, group_similar=False, include_rationale=False, include_for=False, notifications=None, include_notification_type=False):
Pop all messages from stub.test_emails and print them with
their recipients.

Since the same message may be sent more than once (for different recipients), setting 'group_similar' will print each distinct message only once and group all recipients of that message together in the 'To:' field. It will also strip the first line of the email body. (The line with "Hello Foo," which is likely distinct for each recipient.)

Parametersinclude_reply_toInclude the reply-to header if True.
group_similarGroup messages sent to multiple recipients if True.
include_rationaleInclude the X-Launchpad-Message-Rationale header.
include_forInclude the X-Launchpad-Message-For header.
notificationsUse the provided list of notifications instead of the stack.
include_notification_typeInclude the X-Launchpad-Notification-Type header.
def print_distinct_emails(include_reply_to=False, include_rationale=True, include_for=False, include_notification_type=True):
A convenient shortcut for `print_emails`(group_similar=True).
def run_mail_jobs():
Process job queues that send out emails.

If a new job type is added that sends emails, this function can be extended to run those jobs, so that testing emails doesn't require a bunch of different function calls to process different queues.

API Documentation for Launchpad, generated by pydoctor at 2018-05-27 00:00:04.