launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02837
[Merge] lp:~wallyworld/launchpad/mp-related-bugtasks-webservice into lp:launchpad
Ian Booth has proposed merging lp:~wallyworld/launchpad/mp-related-bugtasks-webservice into lp:launchpad with lp:~wallyworld/launchpad/remove-decoratedbug as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/mp-related-bugtasks-webservice/+merge/52004
Export branch merge proposal getReleatedBugTasks as a webservice API.
== Tests ==
Create new TestWebservice test case in lp.code.model.tests.test_branchmergeproposal
Move test test_getMergeProposals_with_merged_revnos() from test_branch
Add new test test_getRelatedBugTasks()
Drive by fix in test_branch to replace hard coded service_root with "self.layer.appserver_root_url('api')"
== Lint ==
Checking for conflicts and issues in changed files.
Linting changed files:
lib/canonical/launchpad/interfaces/_schema_circular_imports.py
lib/lp/code/interfaces/branchmergeproposal.py
lib/lp/code/model/tests/test_branch.py
lib/lp/code/model/tests/test_branchmergeproposal.py
./lib/canonical/launchpad/interfaces/_schema_circular_imports.py
555: E501 line too long (82 characters)
555: Line exceeds 78 characters.
--
https://code.launchpad.net/~wallyworld/launchpad/mp-related-bugtasks-webservice/+merge/52004
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/mp-related-bugtasks-webservice into lp:launchpad.
=== modified file 'lib/canonical/launchpad/interfaces/_schema_circular_imports.py'
--- lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2011-02-24 23:41:43 +0000
+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2011-03-03 13:24:56 +0000
@@ -190,6 +190,8 @@
IBranchMergeProposal['nominateReviewer'].queryTaggedValue(
LAZR_WEBSERVICE_EXPORTED)['return_type'].schema = ICodeReviewVoteReference
IBranchMergeProposal['votes'].value_type.schema = ICodeReviewVoteReference
+patch_collection_return_type(
+ IBranchMergeProposal, 'getRelatedBugTasks', IBugTask)
patch_collection_return_type(IHasBranches, 'getBranches', IBranch)
patch_collection_return_type(
=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py 2011-03-03 13:24:54 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py 2011-03-03 13:24:56 +0000
@@ -40,6 +40,7 @@
export_write_operation,
exported,
operation_parameters,
+ operation_returns_collection_of,
operation_returns_entry,
rename_parameters_as,
REQUEST_USER,
@@ -296,6 +297,9 @@
def getComment(id):
"""Return the CodeReviewComment with the specified ID."""
+ @call_with(user=REQUEST_USER)
+ @operation_returns_collection_of(Interface) # IBugTask
+ @export_read_operation()
def getRelatedBugTasks(user):
"""Return the Bug tasks related to this merge proposal."""
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2011-03-02 04:25:06 +0000
+++ lib/lp/code/model/tests/test_branch.py 2011-03-03 13:24:56 +0000
@@ -12,7 +12,6 @@
datetime,
timedelta,
)
-from unittest import TestLoader
from bzrlib.bzrdir import BzrDir
from bzrlib.revision import NULL_REVISION
@@ -2787,7 +2786,7 @@
db_queue = self.factory.makeBranchMergeQueue()
db_branch = self.factory.makeBranch()
launchpad = launchpadlib_for('test', db_branch.owner,
- service_root="http://api.launchpad.dev:8085")
+ service_root=self.layer.appserver_root_url('api'))
configuration = simplejson.dumps({'test': 'make check'})
@@ -2804,7 +2803,7 @@
with person_logged_in(ANONYMOUS):
db_branch = self.factory.makeBranch()
launchpad = launchpadlib_for('test', db_branch.owner,
- service_root="http://api.launchpad.dev:8085")
+ service_root=self.layer.appserver_root_url('api'))
configuration = simplejson.dumps({'test': 'make check'})
@@ -2814,20 +2813,3 @@
branch2 = ws_object(launchpad, db_branch)
self.assertEqual(branch2.merge_queue_config, configuration)
-
- def test_getMergeProposals_with_merged_revnos(self):
- """Specifying merged revnos selects the correct merge proposal."""
- mp = self.factory.makeBranchMergeProposal()
- launchpad = launchpadlib_for('test', mp.registrant,
- service_root="http://api.launchpad.dev:8085")
- with person_logged_in(mp.registrant):
- mp.markAsMerged(merged_revno=123)
- transaction.commit()
- target = ws_object(launchpad, mp.target_branch)
- mp = ws_object(launchpad, mp)
- self.assertEqual([mp], list(target.getMergeProposals(
- status=['Merged'], merged_revnos=[123])))
-
-
-def test_suite():
- return TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
--- lib/lp/code/model/tests/test_branchmergeproposal.py 2011-03-03 13:24:54 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposal.py 2011-03-03 13:24:56 +0000
@@ -14,7 +14,6 @@
from difflib import unified_diff
from unittest import (
TestCase,
- TestLoader,
)
from lazr.lifecycle.event import ObjectModifiedEvent
@@ -32,6 +31,7 @@
from canonical.launchpad.webapp import canonical_url
from canonical.launchpad.webapp.testing import verifyObject
from canonical.testing.layers import (
+ AppServerLayer,
DatabaseFunctionalLayer,
LaunchpadFunctionalLayer,
LaunchpadZopelessLayer,
@@ -78,10 +78,12 @@
from lp.registry.interfaces.person import IPersonSet
from lp.registry.interfaces.product import IProductSet
from lp.testing import (
+ launchpadlib_for,
login,
login_person,
person_logged_in,
TestCaseWithFactory,
+ ws_object,
)
from lp.testing.factory import (
GPGSigningContext,
@@ -1993,5 +1995,38 @@
self.assertNotIn(r1, partial_revisions)
-def test_suite():
- return TestLoader().loadTestsFromName(__name__)
+class TestWebservice(TestCaseWithFactory):
+ """Tests for the webservice."""
+
+ layer = AppServerLayer
+
+ def test_getMergeProposals_with_merged_revnos(self):
+ """Specifying merged revnos selects the correct merge proposal."""
+ mp = self.factory.makeBranchMergeProposal()
+ launchpad = launchpadlib_for(
+ 'test', mp.registrant,
+ service_root=self.layer.appserver_root_url('api'))
+
+ with person_logged_in(mp.registrant):
+ mp.markAsMerged(merged_revno=123)
+ transaction.commit()
+ target = ws_object(launchpad, mp.target_branch)
+ mp = ws_object(launchpad, mp)
+ self.assertEqual([mp], list(target.getMergeProposals(
+ status=['Merged'], merged_revnos=[123])))
+
+ def test_getRelatedBugTasks(self):
+ """Test the getRelatedBugTasks API."""
+ db_bmp = self.factory.makeBranchMergeProposal()
+ launchpad = launchpadlib_for(
+ 'test', db_bmp.registrant,
+ service_root=self.layer.appserver_root_url('api'))
+
+ with person_logged_in(db_bmp.registrant):
+ db_bug = self.factory.makeBug()
+ db_bmp.source_branch.linkBug(db_bug, db_bmp.registrant)
+ transaction.commit()
+ bmp = ws_object(launchpad, db_bmp)
+ bugtask = ws_object(launchpad, db_bug.default_bugtask)
+ self.assertEqual(
+ [bugtask], list(bmp.getRelatedBugTasks()))