Merge ~cjwatson/launchpad:fix-stormify-message into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: cdbbf0065266f86c4c973ce243ea1e97461bc5fa
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-stormify-message
Merge into: launchpad:master
Diff against target: 35 lines (+7/-3)
1 file modified
lib/lp/bugs/tests/bugs-emailinterface.rst (+7/-3)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+446525@code.launchpad.net

Commit message

Fix bugs-emailinterface.rst after conversion of Message to Storm

Description of the change

The `DecoratedResultSet` used in `Bug.messages` to replace the previous `SQLRelatedJoin(prejoins=["owner"])` can't support `__contains__` without a fair bit of work. Fortunately this wasn't needed very much. There was one use in `Bug.linkMessage` which I already replaced with an explicit Storm query, but I missed the uses of it in `bugs-emailinterface.rst`.

In a test we don't need to care much about performance, so I just used `set(bug.messages)` to materialize the result of the query and turn it into something that supports `__contains__`.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) :
review: Approve
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Would it make sense to add a comment in the tests?

It is currently not obvious when reading the tests why `set` was used. And we will probably trip over it once we convert the doctests to unit tests.

Revision history for this message
Colin Watson (cjwatson) wrote :

Well, I think you'd rather quickly find out that it's needed and put it back ... but sure, I've added a quick comment.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/bugs/tests/bugs-emailinterface.rst b/lib/lp/bugs/tests/bugs-emailinterface.rst
index 6ae9275..1a8a900 100644
--- a/lib/lp/bugs/tests/bugs-emailinterface.rst
+++ b/lib/lp/bugs/tests/bugs-emailinterface.rst
@@ -297,7 +297,11 @@ includes commands, the email has to be OpenPGP-signed.
297 >>> from lp.services.messages.interfaces.message import IMessageSet297 >>> from lp.services.messages.interfaces.message import IMessageSet
298 >>> bug_one = bugset.get(1)298 >>> bug_one = bugset.get(1)
299 >>> added_message = getUtility(IMessageSet).get("<yada-yada-test1>")[0]299 >>> added_message = getUtility(IMessageSet).get("<yada-yada-test1>")[0]
300 >>> added_message in bug_one.messages300
301We use set() here because the DecoratedResultSet used by Bug.messages
302doesn't currently support __contains__.
303
304 >>> added_message in set(bug_one.messages)
301 True305 True
302 >>> print(bug_one.title)306 >>> print(bug_one.title)
303 Better summary307 Better summary
@@ -522,7 +526,7 @@ to the bug:
522526
523 >>> added_message = getUtility(IMessageSet).get("<yada-yada-test3>")[0]527 >>> added_message = getUtility(IMessageSet).get("<yada-yada-test3>")[0]
524 >>> bug_one = bugset.get(1)528 >>> bug_one = bugset.get(1)
525 >>> added_message in bug_one.messages529 >>> added_message in set(bug_one.messages)
526 True530 True
527531
528In these tests, every time we log in, we're fully trusted again:532In these tests, every time we log in, we're fully trusted again:
@@ -2962,7 +2966,7 @@ Attachments sent in replies to existing bugs are stored too.
2962 >>> new_message = getUtility(IMessageSet).get("comment-with-attachment")[2966 >>> new_message = getUtility(IMessageSet).get("comment-with-attachment")[
2963 ... 02967 ... 0
2964 ... ]2968 ... ]
2965 >>> new_message in bug_one.messages2969 >>> new_message in set(bug_one.messages)
2966 True2970 True
2967 >>> print_attachments(new_message.bugattachments)2971 >>> print_attachments(new_message.bugattachments)
2968 LibraryFileAlias attachment.txt text/plain UNSPECIFIED2972 LibraryFileAlias attachment.txt text/plain UNSPECIFIED

Subscribers

People subscribed via source and target branches

to status/vote changes: