~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Andrew Bennetts
  • Date: 2010-05-13 16:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 5232.
  • Revision ID: andrew.bennetts@canonical.com-20100513161754-q2ak6vzjnur7f3i3
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""Tests for the BzrDir facility and any format specific tests.
18
18
 
19
 
For interface contract tests, see tests/bzr_dir_implementations.
 
19
For interface contract tests, see tests/per_bzr_dir.
20
20
"""
21
21
 
22
22
import os
23
 
import os.path
24
 
from StringIO import StringIO
25
23
import subprocess
26
24
import sys
27
25
 
31
29
    help_topics,
32
30
    repository,
33
31
    osutils,
34
 
    symbol_versioning,
35
32
    remote,
36
33
    urlutils,
37
34
    win32utils,
39
36
    )
40
37
import bzrlib.branch
41
38
from bzrlib.errors import (NotBranchError,
 
39
                           NoColocatedBranchSupport,
42
40
                           UnknownFormatError,
43
41
                           UnsupportedFormatError,
44
42
                           )
47
45
    TestCaseWithMemoryTransport,
48
46
    TestCaseWithTransport,
49
47
    TestSkipped,
50
 
    test_sftp_transport
51
48
    )
52
49
from bzrlib.tests import(
53
50
    http_server,
54
51
    http_utils,
55
52
    )
56
53
from bzrlib.tests.test_http import TestWithTransport_pycurl
57
 
from bzrlib.transport import get_transport
 
54
from bzrlib.transport import (
 
55
    get_transport,
 
56
    memory,
 
57
    )
58
58
from bzrlib.transport.http._urllib import HttpTransport_urllib
59
 
from bzrlib.transport.memory import MemoryServer
60
59
from bzrlib.transport.nosmart import NoSmartTransportDecorator
61
60
from bzrlib.transport.readonly import ReadonlyTransportDecorator
62
61
from bzrlib.repofmt import knitrepo, weaverepo, pack_repo
149
148
        new = topics.get_detail('current-formats')
150
149
        rest = topics.get_detail('other-formats')
151
150
        experimental, deprecated = rest.split('Deprecated formats')
152
 
        self.assertContainsRe(new, 'bzr help formats')
 
151
        self.assertContainsRe(new, 'formats-help')
153
152
        self.assertContainsRe(new,
154
153
                ':knit:\n    \(native\) \(default\) Format using knits\n')
155
154
        self.assertContainsRe(experimental,
208
207
        """See BzrDir.open_repository."""
209
208
        return SampleRepository(self)
210
209
 
211
 
    def create_branch(self):
 
210
    def create_branch(self, name=None):
212
211
        """See BzrDir.create_branch."""
 
212
        if name is not None:
 
213
            raise NoColocatedBranchSupport(self)
213
214
        return SampleBranch(self)
214
215
 
215
216
    def create_workingtree(self):
358
359
 
359
360
    def test_create_branch_convenience_root(self):
360
361
        """Creating a branch at the root of a fs should work."""
361
 
        self.vfs_transport_factory = MemoryServer
 
362
        self.vfs_transport_factory = memory.MemoryServer
362
363
        # outside a repo the default convenience output is a repo+branch_tree
363
364
        format = bzrdir.format_registry.make_bzrdir('knit')
364
365
        branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
470
471
        # Make stackable source branch with an unstackable repo format.
471
472
        source_bzrdir = self.make_bzrdir('source')
472
473
        pack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir)
473
 
        source_branch = bzrlib.branch.BzrBranchFormat7().initialize(source_bzrdir)
 
474
        source_branch = bzrlib.branch.BzrBranchFormat7().initialize(
 
475
            source_bzrdir)
474
476
        # Make a directory with a default stacking policy
475
477
        parent_bzrdir = self.make_bzrdir('parent')
476
478
        stacked_on = self.make_branch('parent/stacked-on', format='pack-0.92')
569
571
 
570
572
    def setUp(self):
571
573
        super(ChrootedTests, self).setUp()
572
 
        if not self.vfs_transport_factory == MemoryServer:
 
574
        if not self.vfs_transport_factory == memory.MemoryServer:
573
575
            self.transport_readonly_server = http_server.HttpServer
574
576
 
575
577
    def local_branch_path(self, branch):
1053
1055
 
1054
1056
    def setUp(self):
1055
1057
        super(NonLocalTests, self).setUp()
1056
 
        self.vfs_transport_factory = MemoryServer
 
1058
        self.vfs_transport_factory = memory.MemoryServer
1057
1059
 
1058
1060
    def test_create_branch_convenience(self):
1059
1061
        # outside a repo the default convenience output is a repo+branch_tree
1156
1158
    _transport = HttpTransport_urllib
1157
1159
 
1158
1160
    def _qualified_url(self, host, port):
1159
 
        return 'http+urllib://%s:%s' % (host, port)
 
1161
        result = 'http+urllib://%s:%s' % (host, port)
 
1162
        self.permit_url(result)
 
1163
        return result
1160
1164
 
1161
1165
 
1162
1166
 
1166
1170
    """Tests redirections for pycurl implementation"""
1167
1171
 
1168
1172
    def _qualified_url(self, host, port):
1169
 
        return 'http+pycurl://%s:%s' % (host, port)
 
1173
        result = 'http+pycurl://%s:%s' % (host, port)
 
1174
        self.permit_url(result)
 
1175
        return result
1170
1176
 
1171
1177
 
1172
1178
class TestHTTPRedirections_nosmart(TestHTTPRedirections,
1176
1182
    _transport = NoSmartTransportDecorator
1177
1183
 
1178
1184
    def _qualified_url(self, host, port):
1179
 
        return 'nosmart+http://%s:%s' % (host, port)
 
1185
        result = 'nosmart+http://%s:%s' % (host, port)
 
1186
        self.permit_url(result)
 
1187
        return result
1180
1188
 
1181
1189
 
1182
1190
class TestHTTPRedirections_readonly(TestHTTPRedirections,
1186
1194
    _transport = ReadonlyTransportDecorator
1187
1195
 
1188
1196
    def _qualified_url(self, host, port):
1189
 
        return 'readonly+http://%s:%s' % (host, port)
 
1197
        result = 'readonly+http://%s:%s' % (host, port)
 
1198
        self.permit_url(result)
 
1199
        return result
1190
1200
 
1191
1201
 
1192
1202
class TestDotBzrHidden(TestCaseWithTransport):
1329
1339
        url = transport.base
1330
1340
        err = self.assertRaises(errors.BzrError, bzrdir.BzrDir.open, url)
1331
1341
        self.assertEqual('fail', err._preformatted_string)
 
1342
 
 
1343
    def test_post_repo_init(self):
 
1344
        from bzrlib.bzrdir import RepoInitHookParams
 
1345
        calls = []
 
1346
        bzrdir.BzrDir.hooks.install_named_hook('post_repo_init',
 
1347
            calls.append, None)
 
1348
        self.make_repository('foo')
 
1349
        self.assertLength(1, calls)
 
1350
        params = calls[0]
 
1351
        self.assertIsInstance(params, RepoInitHookParams)
 
1352
        self.assertTrue(hasattr(params, 'bzrdir'))
 
1353
        self.assertTrue(hasattr(params, 'repository'))