~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

Split out repository into .bzr/repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from StringIO import StringIO
23
23
 
 
24
import bzrlib.branch as branch
24
25
import bzrlib.bzrdir as bzrdir
25
26
import bzrlib.errors as errors
26
27
from bzrlib.errors import (NotBranchError,
27
28
                           UnknownFormatError,
28
29
                           UnsupportedFormatError,
29
30
                           )
 
31
import bzrlib.repository as repository
30
32
from bzrlib.tests import TestCase, TestCaseWithTransport
31
33
from bzrlib.transport import get_transport
32
34
from bzrlib.transport.http import HttpServer
33
35
from bzrlib.transport.memory import MemoryServer
 
36
import bzrlib.workingtree as workingtree
34
37
 
35
38
 
36
39
class TestDefaultFormat(TestCase):
49
52
        self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format())
50
53
 
51
54
 
 
55
class SampleBranch(branch.Branch):
 
56
    """A dummy branch for guess what, dummy use."""
 
57
 
 
58
    def __init__(self, dir):
 
59
        self.bzrdir = dir
 
60
 
 
61
 
52
62
class SampleBzrDir(bzrdir.BzrDir):
53
63
    """A sample BzrDir implementation to allow testing static methods."""
54
64
 
58
68
 
59
69
    def create_branch(self):
60
70
        """See BzrDir.create_branch."""
61
 
        return "A branch"
 
71
        return SampleBranch(self)
62
72
 
63
73
    def create_workingtree(self):
64
74
        """See BzrDir.create_workingtree."""
153
163
        bzrdir.BzrDirFormat.set_default_format(format)
154
164
        try:
155
165
            branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url())
156
 
            self.assertEqual('A branch', branch)
 
166
            self.assertTrue(isinstance(branch, SampleBranch))
157
167
        finally:
158
168
            bzrdir.BzrDirFormat.set_default_format(old_format)
159
169
 
196
206
        self.assertEqual('', relpath)
197
207
        branch, relpath = bzrdir.BzrDir.open_containing(self.get_readonly_url('g/p/q'))
198
208
        self.assertEqual('g/p/q', relpath)
 
209
 
 
210
 
 
211
class TestMeta1DirFormat(TestCaseWithTransport):
 
212
    """Tests specific to the meta1 dir format."""
 
213
 
 
214
    def test_right_base_dirs(self):
 
215
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
216
        t = dir.transport
 
217
        branch_base = t.clone('branch').base
 
218
        self.assertEqual(branch_base, dir.get_branch_transport(None).base)
 
219
        self.assertEqual(branch_base,
 
220
                         dir.get_branch_transport(branch.BzrBranchFormat5()).base)
 
221
        repository_base = t.clone('repository').base
 
222
        self.assertEqual(repository_base, dir.get_repository_transport(None).base)
 
223
        self.assertEqual(repository_base,
 
224
                         dir.get_repository_transport(repository.RepositoryFormat7()).base)
 
225
        checkout_base = t.clone('checkout').base
 
226
        self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base)
 
227
        self.assertEqual(checkout_base,
 
228
                         dir.get_workingtree_transport(workingtree.WorkingTreeFormat3()).base)