/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
1
# Copyright (C) 2007 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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
16
7358.14.1 by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id('').
17
"""Tests for Tree.path2id('')"""
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
18
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
19
from breezy.tests.per_tree import TestCaseWithTree
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
20
6793.4.1 by Jelmer Vernooij
Improve set_root_id handling.
21
from breezy.workingtree import SettingFileIdUnsupported
22
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
23
24
class TestGetRootID(TestCaseWithTree):
25
2946.3.4 by John Arbash Meinel
Comment from Martin: Use 'make_tree_*' not 'get_tree_*'
26
    def make_tree_with_default_root_id(self):
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
27
        tree = self.make_branch_and_tree('tree')
28
        return self._convert_tree(tree)
29
2946.3.4 by John Arbash Meinel
Comment from Martin: Use 'make_tree_*' not 'get_tree_*'
30
    def make_tree_with_fixed_root_id(self):
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
31
        tree = self.make_branch_and_tree('tree')
6793.4.1 by Jelmer Vernooij
Improve set_root_id handling.
32
        if not tree.supports_setting_file_ids():
33
            self.assertRaises(
34
                SettingFileIdUnsupported, tree.set_root_id,
6973.9.1 by Jelmer Vernooij
More test fixes.
35
                b'custom-tree-root-id')
6793.4.1 by Jelmer Vernooij
Improve set_root_id handling.
36
            self.skipTest('tree format does not support setting tree id')
6855.4.1 by Jelmer Vernooij
Yet more bees.
37
        tree.set_root_id(b'custom-tree-root-id')
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
38
        return self._convert_tree(tree)
39
40
    def test_get_root_id_default(self):
2946.3.4 by John Arbash Meinel
Comment from Martin: Use 'make_tree_*' not 'get_tree_*'
41
        tree = self.make_tree_with_default_root_id()
6913.3.6 by Jelmer Vernooij
use context manager.
42
        with tree.lock_read():
7358.14.1 by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id('').
43
            self.assertIsNot(None, tree.path2id(''))
2946.3.2 by John Arbash Meinel
Add tree implementation tests for Tree.get_root_id()
44
45
    def test_get_root_id_fixed(self):
2946.3.4 by John Arbash Meinel
Comment from Martin: Use 'make_tree_*' not 'get_tree_*'
46
        tree = self.make_tree_with_fixed_root_id()
6913.3.6 by Jelmer Vernooij
use context manager.
47
        with tree.lock_read():
7358.14.1 by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id('').
48
            self.assertEqual(b'custom-tree-root-id', tree.path2id(''))