39
class AnonymousTestBranchFormat(bzrlib.branch.BranchFormat):
40
"""An anonymous branch format (does not have a format string)"""
42
def get_format_string(self):
43
raise NotImplementedError(self.get_format_string)
46
class IdentifiableTestBranchFormat(bzrlib.branch.BranchFormat):
47
"""An identifable branch format (has a format string)"""
49
def get_format_string(self):
50
return "I have an identity"
53
class AnonymousTestRepositoryFormat(repository.RepositoryFormat):
54
"""An anonymous branch format (does not have a format string)"""
56
def get_format_string(self):
57
raise NotImplementedError(self.get_format_string)
60
class IdentifiableTestRepositoryFormat(repository.RepositoryFormat):
61
"""An identifable branch format (has a format string)"""
63
def get_format_string(self):
64
return "I have an identity"
67
class AnonymousTestWorkingTreeFormat(workingtree.WorkingTreeFormat):
68
"""An anonymous branch format (does not have a format string)"""
70
def get_format_string(self):
71
raise NotImplementedError(self.get_format_string)
74
class IdentifiableTestWorkingTreeFormat(workingtree.WorkingTreeFormat):
75
"""An identifable branch format (has a format string)"""
77
def get_format_string(self):
78
return "I have an identity"
37
81
class TestBzrDir(TestCaseWithBzrDir):
39
83
# Many of these tests test for disk equality rather than checking
490
534
self.failUnless(transport.has('.bzr'))
491
535
self.assertRaises((errors.FileExists, errors.DirectoryNotEmpty),
492
536
bd.retire_bzrdir, limit=0)
538
def test_get_branch_transport(self):
539
dir = self.make_bzrdir('.')
540
# without a format, get_branch_transport gives use a transport
541
# which -may- point to an existing dir.
542
self.assertTrue(isinstance(dir.get_branch_transport(None),
543
transport.Transport))
544
# with a given format, either the bzr dir supports identifiable
545
# branches, or it supports anonymous branch formats, but not both.
546
anonymous_format = AnonymousTestBranchFormat()
547
identifiable_format = IdentifiableTestBranchFormat()
549
found_transport = dir.get_branch_transport(anonymous_format)
550
self.assertRaises(errors.IncompatibleFormat,
551
dir.get_branch_transport,
553
except errors.IncompatibleFormat:
554
found_transport = dir.get_branch_transport(identifiable_format)
555
self.assertTrue(isinstance(found_transport, transport.Transport))
556
# and the dir which has been initialized for us must exist.
557
found_transport.list_dir('.')
559
def test_get_repository_transport(self):
560
dir = self.make_bzrdir('.')
561
# without a format, get_repository_transport gives use a transport
562
# which -may- point to an existing dir.
563
self.assertTrue(isinstance(dir.get_repository_transport(None),
564
transport.Transport))
565
# with a given format, either the bzr dir supports identifiable
566
# repositories, or it supports anonymous repository formats, but not both.
567
anonymous_format = AnonymousTestRepositoryFormat()
568
identifiable_format = IdentifiableTestRepositoryFormat()
570
found_transport = dir.get_repository_transport(anonymous_format)
571
self.assertRaises(errors.IncompatibleFormat,
572
dir.get_repository_transport,
574
except errors.IncompatibleFormat:
575
found_transport = dir.get_repository_transport(identifiable_format)
576
self.assertTrue(isinstance(found_transport, transport.Transport))
577
# and the dir which has been initialized for us must exist.
578
found_transport.list_dir('.')
580
def test_get_workingtree_transport(self):
581
dir = self.make_bzrdir('.')
582
# without a format, get_workingtree_transport gives use a transport
583
# which -may- point to an existing dir.
584
self.assertTrue(isinstance(dir.get_workingtree_transport(None),
585
transport.Transport))
586
# with a given format, either the bzr dir supports identifiable
587
# trees, or it supports anonymous tree formats, but not both.
588
anonymous_format = AnonymousTestWorkingTreeFormat()
589
identifiable_format = IdentifiableTestWorkingTreeFormat()
591
found_transport = dir.get_workingtree_transport(anonymous_format)
592
self.assertRaises(errors.IncompatibleFormat,
593
dir.get_workingtree_transport,
595
except errors.IncompatibleFormat:
596
found_transport = dir.get_workingtree_transport(identifiable_format)
597
self.assertTrue(isinstance(found_transport, transport.Transport))
598
# and the dir which has been initialized for us must exist.
599
found_transport.list_dir('.')