launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19574
[Merge] lp:~cjwatson/launchpad/bmp-created-events into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/bmp-created-events into lp:launchpad with lp:~cjwatson/launchpad/consistent-bmp-events as a prerequisite.
Commit message:
NewBranchMergeProposalEvent and NewCodeReviewCommentEvent are really just ObjectCreatedEvent, so replace the custom events with the generic one.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/bmp-created-events/+merge/273562
NewBranchMergeProposalEvent and NewCodeReviewCommentEvent are really just ObjectCreatedEvent, so replace the custom events with the generic one.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/bmp-created-events into lp:launchpad.
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2015-10-06 16:29:25 +0000
+++ lib/lp/code/configure.zcml 2015-10-06 16:29:26 +0000
@@ -279,7 +279,7 @@
<subscriber
for="lp.code.interfaces.branchmergeproposal.IBranchMergeProposal
- lp.code.interfaces.event.INewBranchMergeProposalEvent"
+ lazr.lifecycle.interfaces.IObjectCreatedEvent"
handler="lp.code.subscribers.branchmergeproposal.merge_proposal_created"/>
<subscriber
for="lp.code.interfaces.branchmergeproposal.IBranchMergeProposal
@@ -291,7 +291,7 @@
handler="lp.code.subscribers.branchmergeproposal.merge_proposal_modified"/>
<subscriber
for="lp.code.interfaces.branchmergeproposal.IBranchMergeProposal
- lp.code.interfaces.event.INewBranchMergeProposalEvent"
+ lazr.lifecycle.interfaces.IObjectCreatedEvent"
handler="lp.code.subscribers.karma.branch_merge_proposed"/>
<subscriber
for="lp.code.interfaces.branchmergeproposal.IBranchMergeProposal
@@ -544,11 +544,11 @@
</class>
<subscriber
for="lp.code.interfaces.codereviewcomment.ICodeReviewComment
- lp.code.interfaces.event.INewCodeReviewCommentEvent"
+ lazr.lifecycle.interfaces.IObjectCreatedEvent"
handler="lp.code.mail.codereviewcomment.send"/>
<subscriber
for="lp.code.interfaces.codereviewcomment.ICodeReviewComment
- lp.code.interfaces.event.INewCodeReviewCommentEvent"
+ lazr.lifecycle.interfaces.IObjectCreatedEvent"
handler="lp.code.subscribers.karma.code_review_comment_added"/>
<!-- CodeReviewInlineComment -->
=== modified file 'lib/lp/code/event/branchmergeproposal.py'
--- lib/lp/code/event/branchmergeproposal.py 2015-10-06 16:29:25 +0000
+++ lib/lp/code/event/branchmergeproposal.py 2015-10-06 16:29:26 +0000
@@ -6,8 +6,6 @@
__metaclass__ = type
__all__ = [
'BranchMergeProposalNeedsReviewEvent',
- 'NewBranchMergeProposalEvent',
- 'NewCodeReviewCommentEvent',
'ReviewerNominatedEvent',
]
@@ -16,17 +14,10 @@
from lp.code.interfaces.event import (
IBranchMergeProposalNeedsReviewEvent,
- INewBranchMergeProposalEvent,
- INewCodeReviewCommentEvent,
IReviewerNominatedEvent,
)
-@implementer(INewBranchMergeProposalEvent)
-class NewBranchMergeProposalEvent(ObjectEvent):
- """A new merge has been proposed."""
-
-
@implementer(IBranchMergeProposalNeedsReviewEvent)
class BranchMergeProposalNeedsReviewEvent(ObjectEvent):
"""The merge proposal has moved from work in progress to needs reivew."""
@@ -35,12 +26,3 @@
@implementer(IReviewerNominatedEvent)
class ReviewerNominatedEvent(ObjectEvent):
"""A reviewer has been nominated."""
-
-
-@implementer(INewCodeReviewCommentEvent)
-class NewCodeReviewCommentEvent(ObjectEvent):
- """A new comment has been added to the merge proposal."""
-
- def __init__(self, code_review_comment, original_email):
- ObjectEvent.__init__(self, code_review_comment)
- self.email = original_email
=== modified file 'lib/lp/code/interfaces/event.py'
--- lib/lp/code/interfaces/event.py 2015-10-06 16:29:25 +0000
+++ lib/lp/code/interfaces/event.py 2015-10-06 16:29:26 +0000
@@ -7,8 +7,6 @@
__all__ = [
'IBranchMergeProposalNeedsReviewEvent',
'IGitRefsUpdatedEvent',
- 'INewBranchMergeProposalEvent',
- 'INewCodeReviewCommentEvent',
'IReviewerNominatedEvent',
]
@@ -16,18 +14,10 @@
from zope.component.interfaces import IObjectEvent
-class INewBranchMergeProposalEvent(IObjectEvent):
- """A new merge has been proposed."""
-
-
class IReviewerNominatedEvent(IObjectEvent):
"""A reviewer has been nominated."""
-class INewCodeReviewCommentEvent(IObjectEvent):
- """A new comment has been added to the merge proposal."""
-
-
class IBranchMergeProposalNeedsReviewEvent(IObjectEvent):
"""The merge proposal has moved from work in progress to needs reivew."""
=== modified file 'lib/lp/code/mail/tests/test_codehandler.py'
--- lib/lp/code/mail/tests/test_codehandler.py 2015-10-06 16:29:25 +0000
+++ lib/lp/code/mail/tests/test_codehandler.py 2015-10-06 16:29:26 +0000
@@ -7,7 +7,10 @@
from textwrap import dedent
-from lazr.lifecycle.event import ObjectModifiedEvent
+from lazr.lifecycle.event import (
+ ObjectCreatedEvent,
+ ObjectModifiedEvent,
+ )
from storm.store import Store
import transaction
from zope.security.management import setSecurityPolicy
@@ -18,7 +21,6 @@
CodeReviewNotificationLevel,
CodeReviewVote,
)
-from lp.code.event.branchmergeproposal import NewCodeReviewCommentEvent
from lp.code.mail.codehandler import (
AddReviewerEmailCommand,
CodeEmailCommands,
@@ -435,7 +437,7 @@
switch_dbuser(config.processmail.dbuser)
login_person(bmp.merge_target.owner)
_, events = self.assertNotifies(
- [ObjectModifiedEvent, NewCodeReviewCommentEvent], False,
+ [ObjectModifiedEvent, ObjectCreatedEvent], False,
self.code_handler.process, mail, email_addr, None)
self.assertEqual(bmp, events[0].object)
self.assertEqual(
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2015-10-05 11:11:47 +0000
+++ lib/lp/code/model/branch.py 2015-10-06 16:29:26 +0000
@@ -13,6 +13,7 @@
from bzrlib import urlutils
from bzrlib.revision import NULL_REVISION
+from lazr.lifecycle.event import ObjectCreatedEvent
import pytz
from sqlobject import (
ForeignKey,
@@ -96,7 +97,6 @@
)
from lp.code.event.branchmergeproposal import (
BranchMergeProposalNeedsReviewEvent,
- NewBranchMergeProposalEvent,
)
from lp.code.interfaces.branch import (
BzrIdentityMixin,
@@ -603,7 +603,7 @@
bmp.nominateReviewer(
reviewer, registrant, review_type, _notify_listeners=False)
- notify(NewBranchMergeProposalEvent(bmp))
+ notify(ObjectCreatedEvent(bmp, user=registrant))
if needs_review:
notify(BranchMergeProposalNeedsReviewEvent(bmp))
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2015-10-06 16:29:25 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2015-10-06 16:29:26 +0000
@@ -12,6 +12,7 @@
from email.utils import make_msgid
+from lazr.lifecycle.event import ObjectCreatedEvent
from sqlobject import (
ForeignKey,
IntCol,
@@ -58,7 +59,6 @@
)
from lp.code.event.branchmergeproposal import (
BranchMergeProposalNeedsReviewEvent,
- NewCodeReviewCommentEvent,
ReviewerNominatedEvent,
)
from lp.code.interfaces.branchcollection import IAllBranches
@@ -935,8 +935,7 @@
vote_reference.review_type = review_type
vote_reference.comment = code_review_message
if _notify_listeners:
- notify(NewCodeReviewCommentEvent(
- code_review_message, original_email))
+ notify(ObjectCreatedEvent(code_review_message))
return code_review_message
def getInlineComments(self, previewdiff_id):
=== modified file 'lib/lp/code/model/gitref.py'
--- lib/lp/code/model/gitref.py 2015-09-30 08:58:44 +0000
+++ lib/lp/code/model/gitref.py 2015-10-06 16:29:26 +0000
@@ -9,6 +9,7 @@
from urllib import quote_plus
+from lazr.lifecycle.event import ObjectCreatedEvent
import pytz
from storm.locals import (
DateTime,
@@ -33,7 +34,6 @@
)
from lp.code.event.branchmergeproposal import (
BranchMergeProposalNeedsReviewEvent,
- NewBranchMergeProposalEvent,
)
from lp.code.interfaces.branch import WrongNumberOfReviewTypeArguments
from lp.code.interfaces.branchmergeproposal import (
@@ -337,7 +337,7 @@
bmp.nominateReviewer(
reviewer, registrant, review_type, _notify_listeners=False)
- notify(NewBranchMergeProposalEvent(bmp))
+ notify(ObjectCreatedEvent(bmp, user=registrant))
if needs_review:
notify(BranchMergeProposalNeedsReviewEvent(bmp))
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
--- lib/lp/code/model/tests/test_branchmergeproposal.py 2015-10-06 16:29:25 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposal.py 2015-10-06 16:29:26 +0000
@@ -12,7 +12,10 @@
from difflib import unified_diff
from unittest import TestCase
-from lazr.lifecycle.event import ObjectModifiedEvent
+from lazr.lifecycle.event import (
+ ObjectCreatedEvent,
+ ObjectModifiedEvent,
+ )
from lazr.restfulclient.errors import BadRequest
from pytz import UTC
from sqlobject import SQLObjectNotFound
@@ -38,8 +41,6 @@
)
from lp.code.event.branchmergeproposal import (
BranchMergeProposalNeedsReviewEvent,
- NewBranchMergeProposalEvent,
- NewCodeReviewCommentEvent,
ReviewerNominatedEvent,
)
from lp.code.interfaces.branchmergeproposal import (
@@ -514,7 +515,7 @@
commenter = self.factory.makePerson()
login_person(commenter)
result, events = self.assertNotifies(
- NewCodeReviewCommentEvent, False,
+ ObjectCreatedEvent, False,
merge_proposal.createComment,
owner=commenter,
subject='A review.')
@@ -654,14 +655,13 @@
def test_notifyOnCreate_needs_review(self):
# When a merge proposal is created needing review, the
# BranchMergeProposalNeedsReviewEvent is raised as well as the usual
- # NewBranchMergeProposalEvent.
+ # ObjectCreatedEvent.
source_branch = self.factory.makeProductBranch()
target_branch = self.factory.makeProductBranch(
product=source_branch.product)
registrant = self.factory.makePerson()
result, events = self.assertNotifies(
- [NewBranchMergeProposalEvent,
- BranchMergeProposalNeedsReviewEvent], False,
+ [ObjectCreatedEvent, BranchMergeProposalNeedsReviewEvent], False,
source_branch.addLandingTarget, registrant, target_branch,
needs_review=True)
self.assertEqual(result, events[0].object)
@@ -674,7 +674,7 @@
product=source_branch.product)
registrant = self.factory.makePerson()
result, events = self.assertNotifies(
- [NewBranchMergeProposalEvent], False,
+ [ObjectCreatedEvent], False,
source_branch.addLandingTarget, registrant, target_branch)
self.assertEqual(result, events[0].object)
=== modified file 'lib/lp/code/model/tests/test_codereviewcomment.py'
--- lib/lp/code/model/tests/test_codereviewcomment.py 2015-10-06 16:29:25 +0000
+++ lib/lp/code/model/tests/test_codereviewcomment.py 2015-10-06 16:29:26 +0000
@@ -5,8 +5,9 @@
from textwrap import dedent
+from lazr.lifecycle.event import ObjectCreatedEvent
+
from lp.code.enums import CodeReviewVote
-from lp.code.event.branchmergeproposal import NewCodeReviewCommentEvent
from lp.code.model.codereviewcomment import quote_text_as_email
from lp.services.messages.model.message import MessageSet
from lp.testing import (
@@ -107,7 +108,7 @@
"""Creating a CodeReviewComment should trigger a notification."""
message = self.factory.makeMessage()
self.assertNotifies(
- NewCodeReviewCommentEvent, False,
+ ObjectCreatedEvent, False,
self.bmp.createCommentFromMessage,
message, None, None, original_email=None, _validate=False)
Follow ups