1
# (C) 2005 Canonical Ltd
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.
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.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Tests for the Branch facility that are not interface tests.
19
For interface tests see test_branch_implementations.py.
21
For concrete class tests see this file, and for meta-branch tests
26
import bzrlib.branch as branch
27
from bzrlib.tests import TestCase, TestCaseInTempDir
30
class TestDefaultFormat(TestCase):
32
def test_get_set_default_initializer(self):
33
old_initializer = Branch.get_default_initializer()
34
# default is BzrBranch._initialize
35
self.assertEqual(branch.BzrBranch._initialize, old_initializer)
37
return "a branch %s" % url
38
branch.Branch.set_default_initializer(recorder)
40
b = branch.Branch.initialize("memory:/")
41
self.assertEqual("a branch memory:/", b)
43
branch.Branch.set_default_initializer(old_initializer)
44
self.assertEqual(old_initializer, branch.Branch.get_default_initializer())
47
class TestBzrBranchFormat(TestCaseInTempDir):
48
"""Tests for the BzrBranchFormat facility."""
50
def test_find_format(self):
51
# is the right format object found for a branch?
52
# create a branch with a few known format objects.
53
# this is not quite the same as
54
self.build_tree(["foo/", "bar/"])
55
def check_format(format, url):
56
format.initialize(url)
57
found_format = branch.BzrBranchFormat.find_format(url)
58
self.failUnless(isinstance(found_format, format.__class__))
59
check_format(branch.BzrBranchFormat5(), "foo")
60
check_format(branch.BzrBranchFormat6(), "bar")
62
def test_initialize_returns_branch(self):
63
self.failUnless(isinstance(branch.BzrBranchFormat5().initialize("."), branch.Branch))