17
17
"""Tests for interface conformance of inventories of trees."""
20
from cStringIO import StringIO
23
20
from bzrlib import (
26
23
from bzrlib.tests import (
30
26
from bzrlib.mutabletree import MutableTree
31
from bzrlib.tests import SymlinkFeature, TestSkipped
27
from bzrlib.tests import TestSkipped
28
from bzrlib.tree import InventoryTree
32
29
from bzrlib.transform import _PreviewTree
33
30
from bzrlib.uncommit import uncommit
141
138
def test_canonical_path(self):
142
139
work_tree = self._make_canonical_test_tree()
140
if not isinstance(work_tree, InventoryTree):
141
raise tests.TestNotApplicable(
142
"test not applicable on non-inventory tests")
143
143
self.assertEqual('dir/file',
144
144
work_tree.get_canonical_inventory_path('Dir/File'))
146
146
def test_canonical_path_before_commit(self):
147
147
work_tree = self._make_canonical_test_tree(False)
148
# note: not committed.
148
if not isinstance(work_tree, InventoryTree):
149
raise tests.TestNotApplicable(
150
"test not applicable on non-inventory tests") # note: not committed.
149
151
self.assertEqual('dir/file',
150
152
work_tree.get_canonical_inventory_path('Dir/File'))
152
154
def test_canonical_path_dir(self):
153
155
# check it works when asked for just the directory portion.
154
156
work_tree = self._make_canonical_test_tree()
157
if not isinstance(work_tree, InventoryTree):
158
raise tests.TestNotApplicable(
159
"test not applicable on non-inventory tests")
155
160
self.assertEqual('dir', work_tree.get_canonical_inventory_path('Dir'))
157
162
def test_canonical_path_root(self):
158
163
work_tree = self._make_canonical_test_tree()
164
if not isinstance(work_tree, InventoryTree):
165
raise tests.TestNotApplicable(
166
"test not applicable on non-inventory tests")
159
167
self.assertEqual('', work_tree.get_canonical_inventory_path(''))
160
168
self.assertEqual('/', work_tree.get_canonical_inventory_path('/'))
162
170
def test_canonical_path_invalid_all(self):
163
171
work_tree = self._make_canonical_test_tree()
172
if not isinstance(work_tree, InventoryTree):
173
raise tests.TestNotApplicable(
174
"test not applicable on non-inventory tests")
164
175
self.assertEqual('foo/bar',
165
176
work_tree.get_canonical_inventory_path('foo/bar'))
167
178
def test_canonical_invalid_child(self):
168
179
work_tree = self._make_canonical_test_tree()
180
if not isinstance(work_tree, InventoryTree):
181
raise tests.TestNotApplicable(
182
"test not applicable on non-inventory tests")
169
183
self.assertEqual('dir/None',
170
184
work_tree.get_canonical_inventory_path('Dir/None'))
180
194
work_tree.add(['test/', 'test/file', 'Test'])
182
196
test_tree = self._convert_tree(work_tree)
197
if not isinstance(test_tree, InventoryTree):
198
raise tests.TestNotApplicable(
199
"test not applicable on non-inventory tests")
183
200
test_tree.lock_read()
184
201
self.addCleanup(test_tree.unlock)