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
17
"""Tests for the test trees used by the tree_implementations tests."""
19
from bzrlib.tests import SymlinkFeature
20
from bzrlib.tests.tree_implementations import TestCaseWithTree
23
class TestTreeShapes(TestCaseWithTree):
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Tests for the test trees used by the per_tree tests."""
19
from bzrlib import tests
20
from bzrlib.tests import per_tree
23
class TestTreeShapes(per_tree.TestCaseWithTree):
25
25
def test_empty_tree_no_parents(self):
26
26
tree = self.make_branch_and_tree('.')
147
147
# currently this test tree requires unicode. It might be good
148
148
# to have it simply stop having the single unicode file in it
149
149
# when dealing with a non-unicode filesystem.
150
self.requireFeature(SymlinkFeature)
150
self.requireFeature(tests.SymlinkFeature)
151
151
tree = self.get_tree_with_subdirs_and_all_content_types()
153
153
self.addCleanup(tree.unlock)
169
# note that the order of the paths and fileids is deliberately
169
# note that the order of the paths and fileids is deliberately
170
170
# mismatched to ensure that the result order is path based.
171
171
self.assertEqual(
172
172
[('', tree_root, 'directory'),
199
199
u'0utf\u1234file'.encode('utf8'),
202
# note that the order of the paths and fileids is deliberately
202
# note that the order of the paths and fileids is deliberately
203
203
# mismatched to ensure that the result order is path based.
204
204
self.assertEqual(
205
205
[('', tree_root, 'directory'),
217
217
revision_id = u'r\xe9v-1'.encode('utf8')
218
218
root_id = 'TREE_ROOT'
219
bar_id = u'b\xe5r-id'.encode('utf8')
220
foo_id = u'f\xf6-id'.encode('utf8')
221
baz_id = u'b\xe1z-id'.encode('utf8')
222
path_and_ids = [(u'', root_id, None),
223
(u'b\xe5r', bar_id, root_id),
224
(u'f\xf6', foo_id, root_id),
225
(u'b\xe5r/b\xe1z', baz_id, bar_id),
219
bar_id = u'ba\N{Euro Sign}r-id'.encode('utf8')
220
foo_id = u'fo\N{Euro Sign}o-id'.encode('utf8')
221
baz_id = u'ba\N{Euro Sign}z-id'.encode('utf8')
222
path_and_ids = [(u'', root_id, None, None),
223
(u'ba\N{Euro Sign}r', bar_id, root_id, revision_id),
224
(u'fo\N{Euro Sign}o', foo_id, root_id, revision_id),
225
(u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
226
baz_id, bar_id, revision_id),
260
261
revision_id_1 = u'r\xe9v-1'.encode('utf8')
261
262
revision_id_2 = u'r\xe9v-2'.encode('utf8')
262
263
root_id = 'TREE_ROOT'
263
bar_id = u'b\xe5r-id'.encode('utf8')
264
foo_id = u'f\xf6-id'.encode('utf8')
265
baz_id = u'b\xe1z-id'.encode('utf8')
266
zez_id = u'z\xf7z-id'.encode('utf8')
264
bar_id = u'ba\N{Euro Sign}r-id'.encode('utf8')
265
foo_id = u'fo\N{Euro Sign}o-id'.encode('utf8')
266
baz_id = u'ba\N{Euro Sign}z-id'.encode('utf8')
267
qux_id = u'qu\N{Euro Sign}x-id'.encode('utf8')
267
268
path_and_ids = [(u'', root_id, None, None),
268
(u'b\xe5r', bar_id, root_id, revision_id_1),
269
(u'f\xf6', foo_id, root_id, revision_id_1),
270
(u'b\xe5r/b\xe1z', baz_id, bar_id, revision_id_1),
271
(u'b\xe5r/z\xf7z', zez_id, bar_id, revision_id_2),
269
(u'ba\N{Euro Sign}r', bar_id, root_id, revision_id_1),
270
(u'fo\N{Euro Sign}o', foo_id, root_id, revision_id_1),
271
(u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
272
baz_id, bar_id, revision_id_1),
273
(u'ba\N{Euro Sign}r/qu\N{Euro Sign}x',
274
qux_id, bar_id, revision_id_2),
279
for expected, (path, ie) in zip(path_and_ids, path_entries):
280
self.assertEqual(expected[0], path) # Paths should match
282
for (epath, efid, eparent, erev), (path, ie) in zip(path_and_ids,
284
self.assertEqual(epath, path) # Paths should match
281
285
self.assertIsInstance(path, unicode)
282
self.assertEqual(expected[1], ie.file_id)
286
self.assertEqual(efid, ie.file_id)
283
287
self.assertIsInstance(ie.file_id, str)
284
self.assertEqual(expected[2], ie.parent_id)
285
if expected[2] is not None:
288
self.assertEqual(eparent, ie.parent_id)
289
if eparent is not None:
286
290
self.assertIsInstance(ie.parent_id, str)
287
291
# WorkingTree's return None for the last modified revision
288
292
if ie.revision is not None:
289
293
self.assertIsInstance(ie.revision, str)
290
if expected[0] == '':
291
295
# Some trees will preserve the revision id of the tree root,
292
296
# but not all will
294
self.assertEqual(expected[3], ie.revision)
298
self.assertEqual(erev, ie.revision)
295
299
self.assertEqual(len(path_and_ids), len(path_entries))
296
300
get_revision_id = getattr(tree, 'get_revision_id', None)
297
301
if get_revision_id is not None: