~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Aaron Bentley
  • Date: 2012-07-12 19:59:24 UTC
  • mto: This revision was merged to the branch mainline in revision 6540.
  • Revision ID: aaron@aaronbentley.com-20120712195924-rptvbf9xiqkc520n
Implement store_uncommitted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
733
733
        self.assertTrue(branch.has_stored_uncommitted())
734
734
        branch._put_uncommitted(None)
735
735
        self.assertFalse(branch.has_stored_uncommitted())
 
736
 
 
737
    def test_store_uncommitted(self):
 
738
 
 
739
        class FakeShelfCreator(object):
 
740
 
 
741
            def __init__(self):
 
742
                self.transform_count = 0
 
743
                self.finalize_count = 0
 
744
 
 
745
            def write_shelf(self, shelf_file, message=None):
 
746
                shelf_file.write('hello')
 
747
 
 
748
            def finalize(self):
 
749
                self.finalize_count += 1
 
750
 
 
751
            def transform(self):
 
752
                self.transform_count += 1
 
753
 
 
754
        branch = self.make_branch('b')
 
755
        creator = FakeShelfCreator()
 
756
        self.assertFalse(branch.has_stored_uncommitted())
 
757
        branch.store_uncommitted(creator)
 
758
        self.assertEqual('hello', branch._get_uncommitted().read())
 
759
        self.assertEqual(1, creator.transform_count)
 
760
        self.assertEqual(1, creator.finalize_count)
 
761
 
 
762
    def test_store_uncommitted_already_stored(self):
 
763
        branch = self.make_branch('b')
 
764
        branch._put_uncommitted(StringIO('hello'))
 
765
        self.assertRaises(errors.ChangesAlreadyStored,
 
766
                          branch.store_uncommitted, None)