Rev 2948: Add tree implementation tests for Tree.get_root_id() in http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/tree_root_id
John Arbash Meinel
john at arbash-meinel.com
Fri Oct 26 20:16:03 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/tree_root_id
------------------------------------------------------------
revno: 2948
revision-id:john at arbash-meinel.com-20071026191529-st3fn58l61g24017
parent: john at arbash-meinel.com-20071026190821-ol840ac6hknunpqd
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: tree_root_id
timestamp: Fri 2007-10-26 14:15:29 -0500
message:
Add tree implementation tests for Tree.get_root_id()
added:
bzrlib/tests/tree_implementations/test_get_root_id.py test_get_root_id.py-20071026191509-a4conhr43f194avv-1
modified:
bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
-------------- next part --------------
=== added file 'bzrlib/tests/tree_implementations/test_get_root_id.py'
--- a/bzrlib/tests/tree_implementations/test_get_root_id.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/tree_implementations/test_get_root_id.py 2007-10-26 19:15:29 +0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Tests for Tree.get_root_id()"""
+
+from bzrlib.tests.tree_implementations import TestCaseWithTree
+
+
+class TestGetRootID(TestCaseWithTree):
+
+ def get_tree_with_default_root_id(self):
+ tree = self.make_branch_and_tree('tree')
+ return self._convert_tree(tree)
+
+ def get_tree_with_fixed_root_id(self):
+ tree = self.make_branch_and_tree('tree')
+ tree.set_root_id('custom-tree-root-id')
+ return self._convert_tree(tree)
+
+ def test_get_root_id_default(self):
+ tree = self.get_tree_with_default_root_id()
+ tree.lock_read()
+ self.addCleanup(tree.unlock)
+ self.assertIsNot(None, tree.get_root_id())
+
+ def test_get_root_id_fixed(self):
+ tree = self.get_tree_with_fixed_root_id()
+ tree.lock_read()
+ self.addCleanup(tree.unlock)
+ self.assertEqual('custom-tree-root-id', tree.get_root_id())
+
=== modified file 'bzrlib/tests/tree_implementations/__init__.py'
--- a/bzrlib/tests/tree_implementations/__init__.py 2007-10-08 07:29:57 +0000
+++ b/bzrlib/tests/tree_implementations/__init__.py 2007-10-26 19:15:29 +0000
@@ -323,6 +323,7 @@
result = TestSuite()
test_tree_implementations = [
'bzrlib.tests.tree_implementations.test_get_file_mtime',
+ 'bzrlib.tests.tree_implementations.test_get_root_id',
'bzrlib.tests.tree_implementations.test_get_symlink_target',
'bzrlib.tests.tree_implementations.test_inv',
'bzrlib.tests.tree_implementations.test_list_files',
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2007-10-11 04:54:04 +0000
+++ b/bzrlib/tree.py 2007-10-26 19:15:29 +0000
@@ -277,6 +277,10 @@
"""
raise NotImplementedError(self.get_symlink_target)
+ def get_root_id(self):
+ """Return the file_id for the root of this tree."""
+ raise NotImplementedError(self.get_root_id)
+
def annotate_iter(self, file_id):
"""Return an iterator of revision_id, line tuples.
More information about the bazaar-commits
mailing list