~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_version_info.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
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
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for version_info"""
18
18
 
53
53
 
54
54
        return wt
55
55
 
 
56
    def test_rio_null(self):
 
57
        wt = self.make_branch_and_tree('branch')
 
58
 
 
59
        sio = StringIO()
 
60
        builder = RioVersionInfoBuilder(wt.branch, working_tree=wt)
 
61
        builder.generate(sio)
 
62
        val = sio.getvalue()
 
63
        self.assertContainsRe(val, 'build-date:')
 
64
        self.assertContainsRe(val, 'revno: 0')
 
65
 
56
66
    def test_rio_version_text(self):
57
67
        wt = self.create_branch()
58
68
 
139
149
        wt.rename_one('b', 'd')
140
150
        stanza = regen(check_for_clean=True, include_file_revisions=True)
141
151
        file_rev_stanza = get_one_stanza(stanza, 'file-revisions')
142
 
        self.assertEqual(['', 'a', 'b', 'c', 'd'], 
 
152
        self.assertEqual(['', 'a', 'b', 'c', 'd'],
143
153
                          file_rev_stanza.get_all('path'))
144
 
        self.assertEqual(['r3', 'modified', 'renamed to d', 'new', 
 
154
        self.assertEqual(['r3', 'modified', 'renamed to d', 'new',
145
155
                          'renamed from b'],
146
156
                         file_rev_stanza.get_all('revision'))
147
157
 
154
164
        self.assertEqual(['r4', 'r4', 'unversioned', 'removed'],
155
165
                         file_rev_stanza.get_all('revision'))
156
166
 
 
167
    def test_python_null(self):
 
168
        wt = self.make_branch_and_tree('branch')
 
169
 
 
170
        sio = StringIO()
 
171
        builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt)
 
172
        builder.generate(sio)
 
173
        val = sio.getvalue()
 
174
        self.assertContainsRe(val, "'revision_id': None")
 
175
        self.assertContainsRe(val, "'revno': 0")
 
176
 
157
177
    def test_python_version(self):
158
178
        wt = self.create_branch()
159
179
 
194
214
        self.build_tree(['branch/c'])
195
215
        tvi = regen(check_for_clean=True, include_file_revisions=True)
196
216
        self.assertEqual(False, tvi.version_info['clean'])
197
 
        self.assertEqual(['', 'a', 'b', 'c'], 
 
217
        self.assertEqual(['', 'a', 'b', 'c'],
198
218
                         sorted(tvi.file_revisions.keys()))
199
219
        self.assertEqual('r3', tvi.file_revisions['a'])
200
220
        self.assertEqual('r2', tvi.file_revisions['b'])
212
232
        wt.add('c')
213
233
        wt.rename_one('b', 'd')
214
234
        tvi = regen(check_for_clean=True, include_file_revisions=True)
215
 
        self.assertEqual(['', 'a', 'b', 'c', 'd'], 
 
235
        self.assertEqual(['', 'a', 'b', 'c', 'd'],
216
236
                          sorted(tvi.file_revisions.keys()))
217
237
        self.assertEqual('modified', tvi.file_revisions['a'])
218
238
        self.assertEqual('renamed to d', tvi.file_revisions['b'])
223
243
        wt.remove(['c', 'd'])
224
244
        os.remove('branch/d')
225
245
        tvi = regen(check_for_clean=True, include_file_revisions=True)
226
 
        self.assertEqual(['', 'a', 'c', 'd'], 
 
246
        self.assertEqual(['', 'a', 'c', 'd'],
227
247
                          sorted(tvi.file_revisions.keys()))
228
248
        self.assertEqual('r4', tvi.file_revisions['a'])
229
249
        self.assertEqual('unversioned', tvi.file_revisions['c'])
230
250
        self.assertEqual('removed', tvi.file_revisions['d'])
231
251
 
 
252
    def test_custom_null(self):
 
253
        sio = StringIO()
 
254
        wt = self.make_branch_and_tree('branch')
 
255
        builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt,
 
256
            template='revno: {revno}')
 
257
        builder.generate(sio)
 
258
        self.assertEquals("revno: 0", sio.getvalue())
 
259
 
 
260
        builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, 
 
261
            template='{revno} revid: {revision_id}')
 
262
        # revision_id is not available yet
 
263
        self.assertRaises(errors.MissingTemplateVariable, 
 
264
            builder.generate, sio)
 
265
 
232
266
    def test_custom_version_text(self):
233
267
        wt = self.create_branch()
234
268