~lifeless/ubuntu/lucid/bzr/2.1.2-sru

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/test_path_content_summary.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-06-27 15:23:34 UTC
  • mfrom: (1.3.1 upstream) (3.1.78 karmic)
  • Revision ID: james.westby@ubuntu.com-20090627152334-u3smexjpaolh96qd
* New upstream release.
* Bump standards version to 3.8.2.

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
"""Test that all Tree's implement path_content_summary."""
18
18
 
19
19
import os
20
20
 
21
 
from bzrlib.osutils import supports_executable, _fs_enc
22
 
from bzrlib.tests import SymlinkFeature, TestSkipped, TestNotApplicable
23
 
from bzrlib.tests.tree_implementations import TestCaseWithTree
24
 
 
25
 
 
26
 
class TestPathContentSummary(TestCaseWithTree):
 
21
from bzrlib import (
 
22
    osutils,
 
23
    tests,
 
24
    )
 
25
 
 
26
from bzrlib.tests import tree_implementations
 
27
 
 
28
 
 
29
class TestPathContentSummary(tree_implementations.TestCaseWithTree):
27
30
 
28
31
    def _convert_tree(self, tree):
29
 
        result = TestCaseWithTree._convert_tree(self, tree)
 
32
        result = tree_implementations.TestCaseWithTree._convert_tree(self, tree)
30
33
        result.lock_read()
31
34
        self.addCleanup(result.unlock)
32
35
        return result
33
36
 
34
37
    def test_symlink_content_summary(self):
35
 
        self.requireFeature(SymlinkFeature)
 
38
        self.requireFeature(tests.SymlinkFeature)
36
39
        tree = self.make_branch_and_tree('tree')
37
40
        os.symlink('target', 'tree/path')
38
41
        tree.add(['path'])
40
43
        self.assertEqual(('symlink', None, None, 'target'), summary)
41
44
 
42
45
    def test_unicode_symlink_content_summary(self):
43
 
        self.requireFeature(SymlinkFeature)
 
46
        self.requireFeature(tests.SymlinkFeature)
 
47
        self.requireFeature(tests.UnicodeFilenameFeature)
44
48
        tree = self.make_branch_and_tree('tree')
45
 
        try:
46
 
            os.symlink('target', u'tree/\u03b2-path'.encode(_fs_enc))
47
 
        except UnicodeError:
48
 
            raise TestSkipped(
49
 
                'This platform does not support unicode file paths.')
50
 
 
 
49
        os.symlink('target', u'tree/\u03b2-path'.encode(osutils._fs_enc))
51
50
        tree.add([u'\u03b2-path'])
52
51
        summary = self._convert_tree(tree).path_content_summary(u'\u03b2-path')
53
52
        self.assertEqual(('symlink', None, None, 'target'), summary)
54
53
 
55
54
    def test_unicode_symlink_target_summary(self):
56
 
        self.requireFeature(SymlinkFeature)
 
55
        self.requireFeature(tests.SymlinkFeature)
 
56
        self.requireFeature(tests.UnicodeFilenameFeature)
57
57
        tree = self.make_branch_and_tree('tree')
58
 
        try:
59
 
            os.symlink(u'tree/\u03b2-path'.encode(_fs_enc), 'tree/link')
60
 
        except UnicodeError:
61
 
            raise TestSkipped(
62
 
                'This platform does not support unicode file paths.')
63
 
 
 
58
        os.symlink(u'tree/\u03b2-path'.encode(osutils._fs_enc), 'tree/link')
64
59
        tree.add(['link'])
65
60
        summary = self._convert_tree(tree).path_content_summary('link')
66
61
        self.assertEqual(('symlink', None, None, u'tree/\u03b2-path'), summary)
71
66
        self.assertEqual(('missing', None, None, None), summary)
72
67
 
73
68
    def test_file_content_summary_executable(self):
74
 
        if not supports_executable():
75
 
            raise TestNotApplicable()
 
69
        if not osutils.supports_executable():
 
70
            raise tests.TestNotApplicable()
76
71
        tree = self.make_branch_and_tree('tree')
77
72
        self.build_tree(['tree/path'])
78
73
        tree.add(['path'])
99
94
        # size must be known
100
95
        self.assertEqual(22, summary[1])
101
96
        # not executable
102
 
        if supports_executable:
 
97
        if osutils.supports_executable:
103
98
            self.assertEqual(False, summary[2])
104
99
        else:
105
100
            self.assertEqual(None, summary[2])
119
114
        subtree = self.make_branch_and_tree('tree/path')
120
115
        tree.add(['path'])
121
116
        if not tree.branch.repository._format.supports_tree_reference:
122
 
            raise TestSkipped("Tree references not supported.")
 
117
            raise tests.TestNotApplicable("Tree references not supported.")
123
118
        summary = self._convert_tree(tree).path_content_summary('path')
124
119
        self.assertEqual(4, len(summary))
125
120
        self.assertEqual('tree-reference', summary[0])