/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
1
# Copyright (C) 2005 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 for version_info
19
"""
20
21
import os
22
23
from bzrlib.tests import TestCase, TestCaseInTempDir
24
from bzrlib.branch import Branch
25
26
# TODO: jam 20051228 When part of bzrlib, this should become
27
#       from bzrlib.generate_version_info import foo
28
29
from generate_version_info import is_clean
30
from errors import UncleanError
31
32
33
class TestIsClean(TestCaseInTempDir):
34
35
    # TODO: jam 20051228 Test that a branch without a working tree
36
    #       is clean. This would be something like an SFTP test
37
38
    def test_is_clean(self):
39
        b = Branch.initialize('.')
40
        wt = b.working_tree()
41
42
        def not_clean(b):
43
            self.assertRaises(UncleanError, is_clean, b)
44
45
        # Nothing happened yet
46
        is_clean(b)
47
48
        # Unknown file
49
        open('a', 'wb').write('a file\n')
50
        not_clean(b)
51
        
52
        # Newly added file
53
        wt.add('a')
54
        not_clean(b)
55
56
        # We committed, things are clean
57
        wt.commit('added a')
58
        is_clean(b)
59
60
        # Unknown
61
        open('b', 'wb').write('b file\n')
62
        not_clean(b)
63
64
        wt.add('b')
65
        not_clean(b)
66
67
        wt.commit('added b')
68
        is_clean(b)
69
70
        open('a', 'wb').write('different\n')
71
        not_clean(b)
72
73
        wt.commit('mod a')
74
        is_clean(b)
75
76
        os.remove('a')
77
        not_clean(b)
78
79
        wt.commit('del a')
80
        is_clean(b)
81
82
        wt.rename_one('b', 'a')
83
        not_clean(b)
84
85
        wt.commit('rename b => a')
86
        is_clean(b)
87
88
89
class TestVersionInfo(TestCaseInTempDir):
90
    pass
91