~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_version_info.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-06 06:48:25 UTC
  • mfrom: (4070.8.6 debug-config)
  • Revision ID: pqm@pqm.ubuntu.com-20090306064825-kbpwggw21dygeix6
(mbp) debug_flags configuration option

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
 
 
66
56
    def test_rio_version_text(self):
67
57
        wt = self.create_branch()
68
58
 
96
86
        self.assertContainsRe(val, 'id: r3')
97
87
        self.assertContainsRe(val, 'message: \xc3\xa52') # utf8 encoding '\xe5'
98
88
 
99
 
    def test_rio_version_hook(self):
100
 
        def update_stanza(rev, stanza):
101
 
            stanza.add('bla', 'bloe')
102
 
        RioVersionInfoBuilder.hooks.install_named_hook(
103
 
            'revision', update_stanza, None)
104
 
        wt = self.create_branch()
105
 
 
106
 
        def regen(**kwargs):
107
 
            sio = StringIO()
108
 
            builder = RioVersionInfoBuilder(wt.branch, working_tree=wt,
109
 
                                            **kwargs)
110
 
            builder.generate(sio)
111
 
            sio.seek(0)
112
 
            stanzas = list(read_stanzas(sio))
113
 
            self.assertEqual(1, len(stanzas))
114
 
            return stanzas[0]
115
 
 
116
 
        stanza = regen()
117
 
        self.assertEqual(['bloe'], stanza.get_all('bla'))
118
 
 
119
89
    def test_rio_version(self):
120
90
        wt = self.create_branch()
121
91
 
184
154
        self.assertEqual(['r4', 'r4', 'unversioned', 'removed'],
185
155
                         file_rev_stanza.get_all('revision'))
186
156
 
187
 
    def test_python_null(self):
188
 
        wt = self.make_branch_and_tree('branch')
189
 
 
190
 
        sio = StringIO()
191
 
        builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt)
192
 
        builder.generate(sio)
193
 
        val = sio.getvalue()
194
 
        self.assertContainsRe(val, "'revision_id': None")
195
 
        self.assertContainsRe(val, "'revno': 0")
196
 
 
197
157
    def test_python_version(self):
198
158
        wt = self.create_branch()
199
159
 
269
229
        self.assertEqual('unversioned', tvi.file_revisions['c'])
270
230
        self.assertEqual('removed', tvi.file_revisions['d'])
271
231
 
272
 
    def test_custom_null(self):
273
 
        sio = StringIO()
274
 
        wt = self.make_branch_and_tree('branch')
275
 
        builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt,
276
 
            template='revno: {revno}')
277
 
        builder.generate(sio)
278
 
        self.assertEquals("revno: 0", sio.getvalue())
279
 
 
280
 
        builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, 
281
 
            template='{revno} revid: {revision_id}')
282
 
        # revision_id is not available yet
283
 
        self.assertRaises(errors.MissingTemplateVariable, 
284
 
            builder.generate, sio)
285
 
 
286
232
    def test_custom_version_text(self):
287
233
        wt = self.create_branch()
288
234