157
157
reviewer=Thing(display_name=u'Reviewer'))]),
159
159
self_link=u'https://api.launchpad.net/1.0/proposal1',
160
web_link=u'https://codelaunchpad.net/proposal1',
160
web_link=u'https://code.launchpad.net/proposal1',
161
161
queue_status=u'Approved',
162
162
commit_message=u'Commit this.',
163
163
source_branch=self.branches[0],
201
201
branch3.lp_branch.unique_name = '~user/branch/' + name
202
202
branch3.lp_branch.landing_candidates = []
203
203
b3_proposal = Thing(
204
self_link=u'http://api.edge.launchpad.net/devel/proposal3',
205
web_link=u'http://edge.launchpad.net/proposal3',
204
self_link=u'https://api.launchpad.net/1.0/proposal3',
205
web_link=u'https://code.launchpad.net/proposal3',
206
206
queue_status=u'Approved',
207
207
commit_message=u'Commitable.',
208
208
source_branch=branch3.lp_branch,
491
491
self.addProposal("one_prerequisite", self.branches[0])
492
492
proposals = self.command._get_prerequisite_proposals(self.proposals[2])
493
493
self.assertEqual(len(proposals), 2)
495
@patch('tarmac.bin.commands.Launchpad.load')
496
def test__get_proposal_from_mp_url(self, mocked):
497
"""Test that the URL is substituted correctly."""
498
self.command.launchpad = MagicMock()
499
self.command.launchpad.load = mocked
500
self.command._get_proposal_from_mp_url(
501
'https://code.launchpad.net/~foo/bar/baz/+merge/10')
502
mocked.assert_called_once_with(
503
'https://api.launchpad.net/1.0/~foo/bar/baz/+merge/10')
505
@patch('tarmac.bin.commands.Launchpad.load')
506
def test__get_proposal_from_mp_url_with_api_url(self, mocked):
507
"""Test that the URL is ignored correctly."""
508
self.command.launchpad = MagicMock()
509
self.command.launchpad.load = mocked
510
self.command._get_proposal_from_mp_url(
511
'https://api.launchpad.net/1.0/~foo/bar/baz/+merge/10')
512
mocked.assert_called_once_with(
513
'https://api.launchpad.net/1.0/~foo/bar/baz/+merge/10')
515
def test_run_merge_with_specific_proposal_without_branch_url(self):
516
"""Test that a specific proposal is merged, with the others ignored."""
517
self.proposals[1].reviewed_revid = \
518
self.branch2.bzr_branch.last_revision()
519
self.addProposal('specific_merge_without_branch_url')
520
self.launchpad.load = MagicMock(return_value=self.proposals[1])
521
self.command._get_reviews = MagicMock()
522
self.config.proposal = self.proposals[1].web_link
523
self.command.run(launchpad=self.launchpad)
524
self.launchpad.load.assert_called_once_with(self.proposals[1].self_link)
525
self.command._get_reviews.assert_called_once_with(self.proposals[1])
527
def test_run_merge_with_specific_proposal_with_branch_url(self):
528
"""Test that a specific proposal is merged, with the others ignored."""
529
self.proposals[1].reviewed_revid = \
530
self.branch2.bzr_branch.last_revision()
531
self.addProposal('specific_merge_with_branch_url')
532
self.launchpad.load = MagicMock(return_value=self.proposals[1])
533
self.command._get_reviews = MagicMock()
534
self.config.proposal = self.proposals[1].web_link
535
self.command.run(launchpad=self.launchpad,
536
branch_url=self.branches[1].bzr_identity)
537
self.launchpad.load.assert_called_once_with(self.proposals[1].self_link)
538
self.command._get_reviews.assert_called_once_with(self.proposals[1])