/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: Aaron Bentley
  • Date: 2006-11-28 19:19:15 UTC
  • mto: This revision was merged to the branch mainline in revision 2155.
  • Revision ID: abentley@panoramicfeedback.com-20061128191915-c6ccc0a12jqylok2
Add additional test that callback is called with a Commit instance

Show diffs side-by-side

added added

removed removed

Lines of Context:
560
560
 
561
561
    class Callback(object):
562
562
        
563
 
        def __init__(self, message):
 
563
        def __init__(self, message, testcase):
564
564
            self.called = False
565
565
            self.message = message
 
566
            self.testcase = testcase
566
567
 
567
 
        def __call__(self, commit_builder):
 
568
        def __call__(self, commit_obj):
568
569
            self.called = True
 
570
            self.testcase.assertTrue(isinstance(commit_obj, Commit))
569
571
            return self.message
570
572
 
571
573
    def test_commit_callback(self):
580
582
                             ' parameter is required for commit().', str(e))
581
583
        else:
582
584
            self.fail('exception not raised')
583
 
        cb = self.Callback(u'commit 1')
 
585
        cb = self.Callback(u'commit 1', self)
584
586
        tree.commit(message_callback=cb)
585
587
        self.assertTrue(cb.called)
586
588
        repository = tree.branch.repository
590
592
    def test_no_callback_pointless(self):
591
593
        """Callback should not be invoked for pointless commit"""
592
594
        tree = self.make_branch_and_tree('.')
593
 
        cb = self.Callback(u'commit 2')
 
595
        cb = self.Callback(u'commit 2', self)
594
596
        self.assertRaises(PointlessCommit, tree.commit, message_callback=cb, 
595
597
                          allow_pointless=False)
596
598
        self.assertFalse(cb.called)
598
600
    def test_no_callback_netfailure(self):
599
601
        """Callback should not be invoked if connectivity fails"""
600
602
        tree = self.make_branch_and_tree('.')
601
 
        cb = self.Callback(u'commit 2')
 
603
        cb = self.Callback(u'commit 2', self)
602
604
        repository = tree.branch.repository
603
605
        # simulate network failure
604
606
        def raise_(self, arg, arg2):