~zyga/tarmac/git-support

« back to all changes in this revision

Viewing changes to tarmac/tests/test_commands.py

  • Committer: Tarmac Traffic Controller
  • Author(s): Rodney Dawes
  • Date: 2014-02-20 20:40:35 UTC
  • mfrom: (427.1.1 merge-web-link)
  • Revision ID: tarmac_traffic_controller-20140220204035-4nrox8da9dk7c127
Use proposal.web_link directly instead of a regex.

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
                        reviewer=Thing(display_name=u'Reviewer'))]),
158
158
                          Thing(
159
159
                self_link=u'https://api.launchpad.net/1.0/proposal1',
160
 
                web_link=u'https://api.launchpad.net/1.0/proposal1',
 
160
                web_link=u'https://codelaunchpad.net/proposal1',
161
161
                queue_status=u'Approved',
162
162
                commit_message=u'Commit this.',
163
163
                source_branch=self.branches[0],
265
265
        self.assertEqual(self.command._get_reviews(self.proposals[1]),
266
266
                         [u'Reviewer;Approve', u'Reviewer2;Abstain'])
267
267
 
268
 
    def test_run_merge_url_substitution(self):
269
 
        """Test that the merge urls get substituted correctly."""
270
 
        self.proposals[1].reviewed_revid = \
271
 
            self.branch2.bzr_branch.last_revision()
272
 
        self.command.run(launchpad=self.launchpad)
273
 
        revid = self.branch1.bzr_branch.last_revision()
274
 
        last_rev = self.branch1.bzr_branch.repository.get_revision(revid)
275
 
        self.assertEqual(last_rev.properties.get('merge_url', None),
276
 
                         u'http://code.launchpad.net/proposal1')
277
 
 
278
 
        # This proposal merged ok
279
 
        self.proposals[1].queue_status = u'Merged'
280
 
 
281
 
        # Make a new commit, approve the propsoal, merge, and verify
282
 
        self.branch2.commit('New commit to merge.')
283
 
        self.proposals[0].queue_status = u'Approved'
284
 
        self.proposals[0].reviewed_revid = \
285
 
            self.branch2.bzr_branch.last_revision()
286
 
        self.command.run(launchpad=self.launchpad)
287
 
        revid = self.branch1.bzr_branch.last_revision()
288
 
        last_rev = self.branch1.bzr_branch.repository.get_revision(revid)
289
 
        self.assertEqual(last_rev.properties.get('merge_url', None),
290
 
                         u'http://code.launchpad.net/proposal0')
291
 
 
292
268
    def test_run_merge_with_unmerged_prerequisite_skips(self):
293
269
        """Test that mereging a branch with an unmerged prerequisite skips."""
294
270
        # Create a 3rd prerequisite branch we'll use to test with
449
425
        self.assertEqual(self.error.comment,
450
426
                         invalid_tree_comment)
451
427
 
452
 
    @patch('tarmac.bin.commands.get_review_url')
453
 
    def test_run_merge_with_list_approved_option(self, mocked):
 
428
    def test_run_merge_with_list_approved_option(self):
454
429
        """Test that --list-approved option prints a list and returns."""
 
430
        tmp_stdout = StringIO()
 
431
        old_stdout = sys.stdout
 
432
        sys.stdout = tmp_stdout
 
433
        self.command.outf = tmp_stdout
 
434
 
455
435
        self.addProposal('list_approved')
 
436
        expected = (self.proposals[1].web_link + '\n' +
 
437
                    self.proposals[2].web_link + '\n')
456
438
        self.command.run(launchpad=self.launchpad, list_approved=True)
457
 
        self.assertEqual(mocked.call_count, 2)
 
439
        self.assertEqual(expected, tmp_stdout.getvalue())
 
440
 
 
441
        sys.stdout = old_stdout
458
442
 
459
443
    def test__compare_proposals(self):
460
444
        """