/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4797.19.2 by John Arbash Meinel
bring in the latest 2.1 changes
1
# Copyright (C) 2007-2010 Canonical Ltd
2338.4.6 by Marien Zwart
Move some tests that do not need a working tree from workingtree_implementations to tree_implementations.
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2338.4.6 by Marien Zwart
Move some tests that do not need a working tree from workingtree_implementations to tree_implementations.
16
17
"""Tests for interface conformance of inventories of trees."""
18
19
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
20
from breezy import (
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
21
    tests,
22
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
23
from breezy.tests import (
4634.131.4 by Martin Pool
test_canonical_tree_name_mismatch needs a case-sensitive filesystem
24
    per_tree,
25
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
26
from breezy.mutabletree import MutableTree
27
from breezy.tests import TestSkipped
28
from breezy.transform import _PreviewTree
29
from breezy.tests import (
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
30
    features,
31
    )
2338.4.6 by Marien Zwart
Move some tests that do not need a working tree from workingtree_implementations to tree_implementations.
32
33
6885.6.1 by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir.
34
def get_entry(tree, path):
7018.3.10 by Jelmer Vernooij
Consistent return values in PreviewTree.list_files.
35
    return next(tree.iter_entries_by_dir(specific_files=[path]))[1]
3363.2.7 by Aaron Bentley
Implement alterntative-to-inventory tests
36
37
7122.4.1 by Jelmer Vernooij
Some refactoring; check for required functionality rather than specific implementation (InventoryTree).
38
class TestTreeWithSymlinks(per_tree.TestCaseWithTree):
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
39
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
40
    _test_needs_features = [features.SymlinkFeature]
4285.2.1 by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests.
41
42
    def setUp(self):
7122.4.1 by Jelmer Vernooij
Some refactoring; check for required functionality rather than specific implementation (InventoryTree).
43
        super(TestTreeWithSymlinks, self).setUp()
2338.4.9 by Marien Zwart
More tests for symlinks in tree inventories.
44
        self.tree = self.get_tree_with_subdirs_and_all_content_types()
45
        self.tree.lock_read()
46
        self.addCleanup(self.tree.unlock)
47
48
    def test_symlink_target(self):
3363.3.1 by Aaron Bentley
Combine test_inv_alternatives and test_inv
49
        if isinstance(self.tree, (MutableTree, _PreviewTree)):
2338.4.9 by Marien Zwart
More tests for symlinks in tree inventories.
50
            raise TestSkipped(
3363.3.1 by Aaron Bentley
Combine test_inv_alternatives and test_inv
51
                'symlinks not accurately represented in working trees and'
52
                ' preview trees')
6885.6.1 by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir.
53
        entry = get_entry(self.tree, 'symlink')
2338.4.9 by Marien Zwart
More tests for symlinks in tree inventories.
54
        self.assertEqual(entry.symlink_target, 'link-target')
55
3363.3.1 by Aaron Bentley
Combine test_inv_alternatives and test_inv
56
    def test_symlink_target_tree(self):
57
        self.assertEqual('link-target',
58
                         self.tree.get_symlink_target('symlink'))
59
60
    def test_kind_symlink(self):
61
        self.assertEqual('symlink', self.tree.kind('symlink'))
62
        self.assertIs(None, self.tree.get_file_size('symlink'))
63
2338.4.9 by Marien Zwart
More tests for symlinks in tree inventories.
64
    def test_symlink(self):
6885.6.1 by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir.
65
        entry = get_entry(self.tree, 'symlink')
2338.4.9 by Marien Zwart
More tests for symlinks in tree inventories.
66
        self.assertEqual(entry.kind, 'symlink')
67
        self.assertEqual(None, entry.text_size)
3363.12.1 by Aaron Bentley
Remove new implementation of paths2ids, implement has_id
68