~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/teststatus.py

  • Committer: Robert Collins
  • Date: 2005-10-03 06:00:44 UTC
  • mto: (1393.1.30)
  • mto: This revision was merged to the branch mainline in revision 1400.
  • Revision ID: robertc@robertcollins.net-20051003060044-2e6d98a7452162b8
implement symlink exporting to tarballs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by 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
 
 
18
"""Tests of status command.
 
19
 
 
20
Most of these depend on the particular formatting used.
 
21
"""
 
22
 
 
23
 
 
24
from bzrlib.selftest import TestCaseInTempDir
 
25
from bzrlib.revisionspec import RevisionSpec
 
26
 
 
27
class BranchStatus(TestCaseInTempDir):
 
28
    
 
29
    def test_branch_status(self): 
 
30
        """Test basic branch status"""
 
31
        from cStringIO import StringIO
 
32
        from bzrlib.status import show_status
 
33
        from bzrlib.branch import Branch
 
34
        
 
35
        b = Branch.initialize('.')
 
36
 
 
37
        # status with nothing
 
38
        tof = StringIO()
 
39
        show_status(b, to_file=tof)
 
40
        self.assertEquals(tof.getvalue(), "")
 
41
 
 
42
        tof = StringIO()
 
43
        self.build_tree(['hello.c', 'bye.c'])
 
44
        b.add_pending_merge('pending@pending-0-0')
 
45
        show_status(b, to_file=tof)
 
46
        tof.seek(0)
 
47
        self.assertEquals(tof.readlines(),
 
48
                          ['unknown:\n',
 
49
                           '  bye.c\n',
 
50
                           '  hello.c\n',
 
51
                           'pending merges:\n',
 
52
                           '  pending@pending-0-0\n'
 
53
                           ])
 
54
 
 
55
    def test_branch_status_revisions(self):
 
56
        """Tests branch status with revisions"""
 
57
        from cStringIO import StringIO
 
58
        from bzrlib.status import show_status
 
59
        from bzrlib.branch import Branch
 
60
        
 
61
        b = Branch.initialize('.')
 
62
 
 
63
        tof = StringIO()
 
64
        self.build_tree(['hello.c', 'bye.c'])
 
65
        b.add('hello.c')
 
66
        b.add('bye.c')
 
67
        b.commit('Test message')
 
68
 
 
69
        tof = StringIO()
 
70
        revs =[]
 
71
        revs.append(RevisionSpec(0))
 
72
        
 
73
        show_status(b, to_file=tof, revision=revs)
 
74
        
 
75
        tof.seek(0)
 
76
        self.assertEquals(tof.readlines(),
 
77
                          ['added:\n',
 
78
                           '  bye.c\n',
 
79
                           '  hello.c\n'])
 
80
 
 
81
        self.build_tree(['more.c'])
 
82
        b.add('more.c')
 
83
        b.commit('Another test message')
 
84
        
 
85
        tof = StringIO()
 
86
        revs.append(RevisionSpec(1))
 
87
        
 
88
        show_status(b, to_file=tof, revision=revs)
 
89
        
 
90
        tof.seek(0)
 
91
        self.assertEquals(tof.readlines(),
 
92
                          ['added:\n',
 
93
                           '  bye.c\n',
 
94
                           '  hello.c\n'])
 
95
 
 
96
    def test_branch_status_specific_files(self): 
 
97
        """Tests branch status with given specific files"""
 
98
        from cStringIO import StringIO
 
99
        from bzrlib.status import show_status
 
100
        from bzrlib.branch import Branch
 
101
        
 
102
        b = Branch.initialize('.')
 
103
 
 
104
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
 
105
        b.add('directory')
 
106
        b.add('test.c')
 
107
        b.commit('testing')
 
108
        
 
109
        tof = StringIO()
 
110
        show_status(b, to_file=tof)
 
111
        tof.seek(0)
 
112
        self.assertEquals(tof.readlines(),
 
113
                          ['unknown:\n',
 
114
                           '  bye.c\n',
 
115
                           '  dir2\n',
 
116
                           '  directory/hello.c\n'
 
117
                           ])
 
118
 
 
119
        tof = StringIO()
 
120
        show_status(b, specific_files=['bye.c','test.c','absent.c'], to_file=tof)
 
121
        tof.seek(0)
 
122
        self.assertEquals(tof.readlines(),
 
123
                          ['unknown:\n',
 
124
                           '  bye.c\n'
 
125
                           ])
 
126
        
 
127
        tof = StringIO()
 
128
        show_status(b, specific_files=['directory'], to_file=tof)
 
129
        tof.seek(0)
 
130
        self.assertEquals(tof.readlines(),
 
131
                          ['unknown:\n',
 
132
                           '  directory/hello.c\n'
 
133
                           ])
 
134
        tof = StringIO()
 
135
        show_status(b, specific_files=['dir2'], to_file=tof)
 
136
        tof.seek(0)
 
137
        self.assertEquals(tof.readlines(),
 
138
                          ['unknown:\n',
 
139
                           '  dir2\n'
 
140
                           ])