~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests.py

  • Committer: Michael Ellerman
  • Date: 2006-02-21 05:02:35 UTC
  • mto: (0.1.73 shelf-tmp)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20060221050235-1cd9e46177de8b92
More tests of shelf show

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
    def test_shelf_show_basic(self):
143
143
        tree = self.make_branch_and_tree('.')
144
144
        self.__create_and_add_test_file(tree)
 
145
        self.__test_show(tree, '00')
145
146
 
 
147
    def __test_show(self, tree, patch):
146
148
        # Modify the test file
147
 
        self.build_tree_contents([('test_file', self.MODIFIED)])
 
149
        self.build_tree_contents([('test_file', 'patch %s\n' % patch)])
148
150
 
149
151
        # Shelve the changes
150
152
        self.run_bzr('shelve', retcode=0)
154
156
 
155
157
        # Check the shelf is right
156
158
        shelf = open(os.path.join(tree.branch.base,
 
159
                    '.shelf/shelves/default', patch)).read()
 
160
        self.assertTrue('patch %s' % patch in shelf)
 
161
 
 
162
        # Check the shown output is right
 
163
        shown = self.capture('shelf show %s' % patch, retcode=0)
 
164
        self.assertEqual(shown, shelf)
 
165
 
 
166
    def test_shelf_show_multi(self):
 
167
        tree = self.make_branch_and_tree('.')
 
168
        self.__create_and_add_test_file(tree)
 
169
        self.__test_show(tree, '00')
 
170
        self.__test_show(tree, '01')
 
171
        self.__test_show(tree, '02')
 
172
 
 
173
        # Now check we can show a previously shelved patch
 
174
        shelf = open(os.path.join(tree.branch.base,
157
175
                    '.shelf/shelves/default/00')).read()
158
 
        shelf = shelf[shelf.index('\n') + 1:] # skip the message
159
 
        self.assertEqual(shelf, self.DIFF_1)
 
176
        self.assertTrue('patch 00' in shelf)
160
177
 
161
178
        # Check the shown output is right
162
179
        shown = self.capture('shelf show 00', retcode=0)
163
 
        shown = shown[shown.index('\n') + 1:] # skip the message
164
180
        self.assertEqual(shown, shelf)