~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_ls_shelf.py

  • Committer: Aaron Bentley
  • Date: 2008-12-02 05:35:51 UTC
  • mto: This revision was merged to the branch mainline in revision 3893.
  • Revision ID: aaron@aaronbentley.com-20081202053551-1f8ifkqem116sudi
Implement ls-shelf command

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
from bzrlib import shelf
 
18
from bzrlib.tests import TestCaseWithTransport
 
19
 
 
20
class TestLSShelf(TestCaseWithTransport):
 
21
 
 
22
    def test_no_shelved_changes(self):
 
23
        tree = self.make_branch_and_tree('.')
 
24
        err = self.run_bzr('ls-shelf')[1]
 
25
        self.assertEqual('No shelved changes.\n', err)
 
26
 
 
27
    def test_shelve_one(self):
 
28
        tree = self.make_branch_and_tree('.')
 
29
        creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
 
30
        shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
 
31
        out, err = self.run_bzr('ls-shelf', retcode=1)
 
32
        self.assertEqual('', err)
 
33
        self.assertEqual('  1: Foo\n', out)
 
34
 
 
35
    def test_shelve_no_message(self):
 
36
        tree = self.make_branch_and_tree('.')
 
37
        creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
 
38
        shelf_id = tree.get_shelf_manager().shelve_changes(creator)
 
39
        out, err = self.run_bzr('ls-shelf', retcode=1)
 
40
        self.assertEqual('', err)
 
41
        self.assertEqual('  1: <no message>\n', out)
 
42
 
 
43
    def test_shelf_order(self):
 
44
        tree = self.make_branch_and_tree('.')
 
45
        creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
 
46
        tree.get_shelf_manager().shelve_changes(creator, 'Foo')
 
47
        creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
 
48
        tree.get_shelf_manager().shelve_changes(creator, 'Bar')
 
49
        out, err = self.run_bzr('ls-shelf', retcode=1)
 
50
        self.assertEqual('', err)
 
51
        self.assertEqual('  2: Bar\n  1: Foo\n', out)