launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26477
[Merge] ~cjwatson/launchpad:py3-distribution-mirror-email-sorting into launchpad:master
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']
- 'mark@xxxxxxxxxxx,karl@xxxxxxxxxxxxx'
- >>> from_addr, to_addr, raw_message = stub.test_emails.pop()
- >>> msg = message_from_bytes(raw_message)
- >>> msg['To']
- 'mark@xxxxxxxxxxx'
+ >>> 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)))
+ ['karl@xxxxxxxxxxxxx', 'mark@xxxxxxxxxxx']
+ >>> from_addr, to_addrs, raw_message = stub.test_emails.pop(0)
+ >>> print(pretty(sorted(to_addrs)))
+ ['mark@xxxxxxxxxxx']
>>> 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']
- 'mark@xxxxxxxxxxx,karl@xxxxxxxxxxxxx'
+ >>> from_addr, to_addrs, raw_message = stub.test_emails.pop()
+ >>> print(pretty(sorted(to_addrs)))
+ ['karl@xxxxxxxxxxxxx', 'mark@xxxxxxxxxxx']
Now we delete the MirrorProbeRecord we've just created, to make
sure this mirror is probed by our prober script.