Colin Watson has proposed merging
~cjwatson/launchpad:py3-distribution-mirror-email-sorting into launchpad:master.
Commit message:
Fix email sorting in distribution-mirror.txt
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398905
The order of recipients isn't guaranteed, so we need to do some additional
sorting.
--
Your team Launchpad code reviewers is requested to review the proposed merge of
~cjwatson/launchpad:py3-distribution-mirror-email-sorting into launchpad:master.
diff --git a/lib/lp/registry/doc/distribution-mirror.txt b/lib/lp/registry/doc/distribution-mirror.txt
index 05e9857..b4fd20a 100644
--- a/lib/lp/registry/doc/distribution-mirror.txt
+++ b/lib/lp/registry/doc/distribution-mirror.txt
@@ -364,17 +364,16 @@ up on the public mirror listings.
>>> from lp.services.mail import stub
>>> len(stub.test_emails)
2
- >>> stub.test_emails.sort(key=itemgetter(1)) # sort by to_addr
- >>> from_addr, to_addr, raw_message = stub.test_emails.pop()
- >>> msg = message_from_bytes(raw_message)
- >>> msg['To']
- '[email protected],[email protected]'
- >>> from_addr, to_addr, raw_message = stub.test_emails.pop()
- >>> msg = message_from_bytes(raw_message)
- >>> msg['To']
- '[email protected]'
+ >>> stub.test_emails.sort(key=lambda e: sorted(e[1])) # sort by to_addr
+ >>> from_addr, to_addrs, raw_message = stub.test_emails.pop(0)
+ >>> print(pretty(sorted(to_addrs)))
+ ['[email protected]', '[email protected]']
+ >>> from_addr, to_addrs, raw_message = stub.test_emails.pop(0)
+ >>> print(pretty(sorted(to_addrs)))
+ ['[email protected]']
>>> valid_mirror.enabled
False
+ >>> msg = message_from_bytes(raw_message)
>>> print(msg.get_payload())
Dear mirror administrator,
<BLANKLINE>
@@ -399,10 +398,9 @@ single notification to the distribution's mirror admins.
>>> transaction.commit()
>>> len(stub.test_emails)
1
- >>> from_addr, to_addr, raw_message = stub.test_emails.pop()
- >>> msg = message_from_bytes(raw_message)
- >>> msg['To']
- '[email protected],[email protected]'
+ >>> from_addr, to_addrs, raw_message = stub.test_emails.pop()
+ >>> print(pretty(sorted(to_addrs)))
+ ['[email protected]', '[email protected]']
Now we delete the MirrorProbeRecord we've just created, to make
sure this mirror is probed by our prober script.
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help : https://help.launchpad.net/ListHelp