Rev 370: More tests. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Wed Jan 3 07:13:48 GMT 2007
------------------------------------------------------------
revno: 370
revision-id: jelmer at samba.org-20070103071312-9ncpsbv28tn3w19p
parent: jelmer at samba.org-20070103052419-l1ynpmaau0qyl9rq
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Wed 2007-01-03 08:13:12 +0100
message:
More tests.
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
tests/test_branch.py test_branch.py-20060508162215-74ffeb5d608f8e20
tests/test_branchprops.py test_branchprops.py-20061223210444-04xf5224zcg69m3w-1
tests/test_logwalker.py test_logwalker.py-20060622141944-pkocc3rj8g62ukbi-1
tests/test_repos.py test_repos.py-20060508151940-ddc49a59257ca712
tests/test_scheme.py test_scheme.py-20060621221855-va2xabhlxpmc9llx-1
=== modified file 'branch.py'
--- a/branch.py 2007-01-02 15:04:08 +0000
+++ b/branch.py 2007-01-03 07:13:12 +0000
@@ -128,12 +128,9 @@
return inv.root.file_id
def _get_nick(self):
- try:
- if self.branch_path == "":
- return None
- return self.branch_path.strip("/")
- except ValueError:
+ if self.branch_path == "":
return None
+ return self.branch_path.strip("/")
nick = property(_get_nick)
@@ -165,7 +162,7 @@
if ph:
return ph[-1]
else:
- return none
+ return None
def pull(self, source, overwrite=False, stop_revision=None):
source.lock_read()
@@ -175,7 +172,7 @@
self.update_revisions(source, stop_revision)
except DivergedBranches:
if overwrite:
- raise BzrError('overwrite not supported for Subversion branches')
+ raise NotImplementedError('overwrite not supported for Subversion branches')
raise
new_count = len(self.revision_history())
return new_count - old_count
=== modified file 'fileids.py'
--- a/fileids.py 2007-01-03 05:24:19 +0000
+++ b/fileids.py 2007-01-03 07:13:12 +0000
@@ -141,10 +141,8 @@
return self._apply_changes(lambda x: generate_file_id(revid, x),
changes, get_children)
- def get_map(self, uuid, revnum, branch, renames_cb=None):
+ def get_map(self, uuid, revnum, branch, renames_cb):
"""Make sure the map is up to date until revnum."""
- if renames_cb is None:
- renames_cb = lambda x: {}
# First, find the last cached map
todo = []
next_parent_revs = []
=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py 2007-01-02 15:04:08 +0000
+++ b/tests/test_branch.py 2007-01-03 07:13:12 +0000
@@ -26,13 +26,24 @@
import svn.core, svn.client
-from branch import FakeControlFiles
+from branch import FakeControlFiles, SvnBranchFormat
from convert import load_dumpfile
import format
from repository import MAPPING_VERSION
from tests import TestCaseWithSubversionRepository
class WorkingSubversionBranch(TestCaseWithSubversionRepository):
+ def test_last_rev_rev_hist(self):
+ repos_url = self.make_client("a", "dc")
+ branch = Branch.open(repos_url)
+ branch.revision_history()
+ self.assertEqual(None, branch.last_revision())
+
+ def test_set_parent(self):
+ repos_url = self.make_client('a', 'dc')
+ branch = Branch.open(repos_url)
+ branch.set_parent("foobar")
+
def test_num_revnums(self):
repos_url = self.make_client('a', 'dc')
bzrdir = BzrDir.open("svn+"+repos_url)
@@ -64,16 +75,34 @@
branch = Branch.open("svn+"+repos_url)
self.assertRaises(NotImplementedError, branch.set_revision_history, [])
- def test_get_root_id(self):
+ def test_get_root_id_empty(self):
repos_url = self.make_client('a', 'dc')
branch = Branch.open("svn+"+repos_url)
self.assertEqual(ROOT_ID, branch.get_root_id())
+ def test_get_root_id_trunk(self):
+ repos_url = self.make_client('a', 'dc')
+ self.build_tree({'dc/trunk': None})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "msg")
+ branch = Branch.open("svn+"+repos_url+"/trunk")
+ self.assertEqual(ROOT_ID, branch.get_root_id())
+
def test_break_lock(self):
repos_url = self.make_client('a', 'dc')
branch = Branch.open("svn+"+repos_url)
branch.control_files.break_lock()
+ def test_repr(self):
+ repos_url = self.make_client('a', 'dc')
+ branch = Branch.open("svn+"+repos_url)
+ self.assertEqual("SvnBranch('svn+%s')" % repos_url, branch.__repr__())
+
+ def test_get_physical_lock_status(self):
+ repos_url = self.make_client('a', 'dc')
+ branch = Branch.open("svn+"+repos_url)
+ self.assertFalse(branch.get_physical_lock_status())
+
def test_set_push_location(self):
repos_url = self.make_client('a', 'dc')
branch = Branch.open("svn+"+repos_url)
@@ -555,3 +584,17 @@
f = FakeControlFiles()
self.assertRaises(NoSuchFile, f.get, "foobla")
+class BranchFormatTests(TestCase):
+ def setUp(self):
+ self.format = SvnBranchFormat()
+
+ def test_initialize(self):
+ self.assertRaises(NotImplementedError, self.format.initialize, None)
+
+ def test_get_format_string(self):
+ self.assertEqual("Subversion Smart Server",
+ self.format.get_format_string())
+
+ def test_get_format_description(self):
+ self.assertEqual("Subversion Smart Server",
+ self.format.get_format_description())
=== modified file 'tests/test_branchprops.py'
--- a/tests/test_branchprops.py 2006-12-26 16:42:50 +0000
+++ b/tests/test_branchprops.py 2007-01-03 07:13:12 +0000
@@ -14,6 +14,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+from bzrlib.errors import NoSuchRevision
+
from tests import TestCaseWithSubversionRepository
from branchprops import BranchPropertyList
from logwalker import LogWalker
@@ -40,6 +42,16 @@
bp = BranchPropertyList(logwalk, self.db)
self.assertEqual("data", bp.get_property("", 1, "myprop"))
+ def test_get_property_norev(self):
+ repos_url = self.make_client('d', 'dc')
+ self.client_set_prop("dc", "myprop", "data")
+ self.client_commit("dc", "My Message")
+
+ logwalk = LogWalker(transport=SvnRaTransport(repos_url))
+
+ bp = BranchPropertyList(logwalk, self.db)
+ self.assertRaises(NoSuchRevision, bp.get_property, "", 10, "myprop")
+
def test_get_old_property(self):
repos_url = self.make_client('d', 'dc')
self.client_set_prop("dc", "myprop", "data")
@@ -90,3 +102,15 @@
bp = BranchPropertyList(logwalk, self.db)
self.assertEqual("data2\n", bp.get_property_diff("", 2, "myprop"))
+
+ def test_get_property_diff_ignore_origchange(self):
+ repos_url = self.make_client('d', 'dc')
+ self.client_set_prop("dc", "myprop", "foodata\n")
+ self.client_commit("dc", "My Message")
+ self.client_set_prop("dc", "myprop", "data\ndata2\n")
+ self.client_commit("dc", "My Message")
+
+ logwalk = LogWalker(transport=SvnRaTransport(repos_url))
+
+ bp = BranchPropertyList(logwalk, self.db)
+ self.assertEqual("", bp.get_property_diff("", 2, "myprop"))
=== modified file 'tests/test_logwalker.py'
--- a/tests/test_logwalker.py 2007-01-02 16:58:01 +0000
+++ b/tests/test_logwalker.py 2007-01-03 07:13:12 +0000
@@ -317,6 +317,13 @@
self.assertFalse(walker.touches_path("trunk", 2))
+ def test_get_previous_root(self):
+ repos_url = self.make_client("a", "dc")
+
+ walker = logwalker.LogWalker(transport=SvnRaTransport(repos_url))
+
+ self.assertEqual((None, -1), walker.get_previous("", 0))
+
def test_get_previous_simple(self):
repos_url = self.make_client("a", "dc")
self.build_tree({'dc/trunk/afile': "data"})
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2007-01-02 17:31:01 +0000
+++ b/tests/test_repos.py 2007-01-03 07:13:12 +0000
@@ -16,7 +16,7 @@
from bzrlib.branch import Branch
from bzrlib.bzrdir import BzrDir
-from bzrlib.errors import NoSuchRevision, BzrError
+from bzrlib.errors import NoSuchRevision, BzrError, UninitializableFormat
from bzrlib.inventory import Inventory
import bzrlib.osutils as osutils
from bzrlib.repository import Repository
@@ -38,7 +38,8 @@
import repository
from repository import (parse_svn_revision_id, generate_svn_revision_id,
svk_feature_to_revision_id, revision_id_to_svk_feature,
- MAPPING_VERSION, escape_svn_path, unescape_svn_path)
+ MAPPING_VERSION, escape_svn_path, unescape_svn_path,
+ SvnRepositoryFormat)
class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
@@ -66,6 +67,23 @@
repos = Repository.open(repos_url)
self.assertFalse(repos.make_working_trees())
+ def test_set_make_working_trees(self):
+ repos_url = self.make_client("a", "dc")
+ repos = Repository.open(repos_url)
+ repos.set_make_working_trees(True)
+ self.assertFalse(repos.make_working_trees())
+
+ def test_add_revision(self):
+ repos_url = self.make_client("a", "dc")
+ repos = Repository.open(repos_url)
+ self.assertRaises(NotImplementedError, repos.add_revision, "revid",
+ None)
+
+ def test_has_signature_for_revision_id(self):
+ repos_url = self.make_client("a", "dc")
+ repos = Repository.open(repos_url)
+ self.assertFalse(repos.has_signature_for_revision_id("foo"))
+
def test_repr(self):
repos_url = self.make_client("a", "dc")
self.build_tree({'dc/foo': "data"})
@@ -276,6 +294,11 @@
fs = self.open_fs('c')
self.assertEqual(svn.fs.get_uuid(fs), repository.uuid)
+ def test_get_inventory_weave(self):
+ bzrdir = self.make_client_and_bzrdir('d', 'dc')
+ repository = bzrdir.find_repository()
+ self.assertRaises(NotImplementedError, repository.get_inventory_weave)
+
def test_has_revision(self):
bzrdir = self.make_client_and_bzrdir('d', 'dc')
repository = bzrdir.find_repository()
@@ -381,11 +404,20 @@
"svn-v%d:1@%s-" % (MAPPING_VERSION, repository.uuid)))
self.assertEqual([None], repository.get_ancestry(None))
- def test_get_revision_graph(self):
+ def test_get_revision_graph_empty(self):
+ repos_url = self.make_client('d', 'dc')
+ repository = Repository.open("svn+%s" % repos_url)
+ self.assertEqual({}, repository.get_revision_graph(NULL_REVISION))
+
+ def test_get_revision_graph_invalid(self):
repos_url = self.make_client('d', 'dc')
repository = Repository.open("svn+%s" % repos_url)
self.assertRaises(NoSuchRevision, repository.get_revision_graph,
"nonexisting")
+
+ def test_get_revision_graph(self):
+ repos_url = self.make_client('d', 'dc')
+ repository = Repository.open("svn+%s" % repos_url)
self.build_tree({'dc/foo': "data"})
self.client_add("dc/foo")
self.client_commit("dc", "My Message")
@@ -1919,3 +1951,14 @@
def test_unescape_svn_path_percent(self):
self.assertEqual("foobar%b", unescape_svn_path("foobar%25b"))
+
+class SvnRepositoryFormatTests(TestCase):
+ def setUp(self):
+ self.format = SvnRepositoryFormat()
+
+ def test_initialize(self):
+ self.assertRaises(UninitializableFormat, self.format.initialize, None)
+
+ def test_get_format_description(self):
+ self.assertEqual("Subversion Repository",
+ self.format.get_format_description())
=== modified file 'tests/test_scheme.py'
--- a/tests/test_scheme.py 2007-01-02 17:05:41 +0000
+++ b/tests/test_scheme.py 2007-01-03 07:13:12 +0000
@@ -21,6 +21,17 @@
BranchingScheme, TrunkBranchingScheme)
class BranchingSchemeTest(TestCase):
+ def test_is_branch(self):
+ self.assertRaises(NotImplementedError, BranchingScheme().is_branch, "")
+
+ def test_is_branch_parent(self):
+ self.assertRaises(NotImplementedError,
+ BranchingScheme().is_branch_parent, "")
+
+ def test_unprefix(self):
+ self.assertRaises(NotImplementedError,
+ BranchingScheme().unprefix, "")
+
def test_guess_empty(self):
self.assertIsInstance(BranchingScheme.guess_scheme(""),
NoBranchingScheme)
More information about the bazaar-commits
mailing list