42
59
old_format = bzrdir.BzrDirFormat.get_default_format()
43
60
# default is BzrDirFormat6
44
61
self.failUnless(isinstance(old_format, bzrdir.BzrDirMetaFormat1))
45
bzrdir.BzrDirFormat.set_default_format(SampleBzrDirFormat())
62
self.applyDeprecated(symbol_versioning.zero_fourteen,
63
bzrdir.BzrDirFormat.set_default_format,
46
65
# creating a bzr dir should now create an instrumented dir.
48
67
result = bzrdir.BzrDir.create('memory:///')
49
68
self.failUnless(isinstance(result, SampleBzrDir))
51
bzrdir.BzrDirFormat.set_default_format(old_format)
70
self.applyDeprecated(symbol_versioning.zero_fourteen,
71
bzrdir.BzrDirFormat.set_default_format, old_format)
52
72
self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format())
75
class TestFormatRegistry(TestCase):
77
def make_format_registry(self):
78
my_format_registry = bzrdir.BzrDirFormatRegistry()
79
my_format_registry.register('weave', bzrdir.BzrDirFormat6,
80
'Pre-0.8 format. Slower and does not support checkouts or shared'
81
' repositories', deprecated=True)
82
my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir',
83
'BzrDirFormat6', 'Format registered lazily', deprecated=True)
84
my_format_registry.register_metadir('knit',
85
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
88
my_format_registry.set_default('knit')
89
my_format_registry.register_metadir(
91
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
92
'Experimental successor to knit. Use at your own risk.',
93
branch_format='bzrlib.branch.BzrBranchFormat6')
94
my_format_registry.register_metadir(
96
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
97
'Experimental successor to knit. Use at your own risk.',
98
branch_format='bzrlib.branch.BzrBranchFormat6', hidden=True)
99
my_format_registry.register('hiddenweave', bzrdir.BzrDirFormat6,
100
'Pre-0.8 format. Slower and does not support checkouts or shared'
101
' repositories', hidden=True)
102
my_format_registry.register_lazy('hiddenlazy', 'bzrlib.bzrdir',
103
'BzrDirFormat6', 'Format registered lazily', deprecated=True,
105
return my_format_registry
107
def test_format_registry(self):
108
my_format_registry = self.make_format_registry()
109
my_bzrdir = my_format_registry.make_bzrdir('lazy')
110
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
111
my_bzrdir = my_format_registry.make_bzrdir('weave')
112
self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
113
my_bzrdir = my_format_registry.make_bzrdir('default')
114
self.assertIsInstance(my_bzrdir.repository_format,
115
knitrepo.RepositoryFormatKnit1)
116
my_bzrdir = my_format_registry.make_bzrdir('knit')
117
self.assertIsInstance(my_bzrdir.repository_format,
118
knitrepo.RepositoryFormatKnit1)
119
my_bzrdir = my_format_registry.make_bzrdir('branch6')
120
self.assertIsInstance(my_bzrdir.get_branch_format(),
121
bzrlib.branch.BzrBranchFormat6)
123
def test_get_help(self):
124
my_format_registry = self.make_format_registry()
125
self.assertEqual('Format registered lazily',
126
my_format_registry.get_help('lazy'))
127
self.assertEqual('Format using knits',
128
my_format_registry.get_help('knit'))
129
self.assertEqual('Format using knits',
130
my_format_registry.get_help('default'))
131
self.assertEqual('Pre-0.8 format. Slower and does not support'
132
' checkouts or shared repositories',
133
my_format_registry.get_help('weave'))
135
def test_help_topic(self):
136
topics = help_topics.HelpTopicRegistry()
137
topics.register('formats', self.make_format_registry().help_topic,
139
topic = topics.get_detail('formats')
140
new, deprecated = topic.split('Deprecated formats')
141
self.assertContainsRe(new, 'Bazaar directory formats')
142
self.assertContainsRe(new,
143
' knit/default:\n \(native\) Format using knits\n')
144
self.assertContainsRe(deprecated,
145
' lazy:\n \(native\) Format registered lazily\n')
146
self.assertNotContainsRe(new, 'hidden')
148
def test_set_default_repository(self):
149
default_factory = bzrdir.format_registry.get('default')
150
old_default = [k for k, v in bzrdir.format_registry.iteritems()
151
if v == default_factory and k != 'default'][0]
152
bzrdir.format_registry.set_default_repository('dirstate-with-subtree')
154
self.assertIs(bzrdir.format_registry.get('dirstate-with-subtree'),
155
bzrdir.format_registry.get('default'))
157
repository.RepositoryFormat.get_default_format().__class__,
158
knitrepo.RepositoryFormatKnit3)
160
bzrdir.format_registry.set_default_repository(old_default)
55
163
class SampleBranch(bzrlib.branch.Branch):
56
164
"""A dummy branch for guess what, dummy use."""
156
264
def test_create_repository(self):
157
265
format = SampleBzrDirFormat()
158
old_format = bzrdir.BzrDirFormat.get_default_format()
159
bzrdir.BzrDirFormat.set_default_format(format)
161
repo = bzrdir.BzrDir.create_repository(self.get_url())
162
self.assertEqual('A repository', repo)
164
bzrdir.BzrDirFormat.set_default_format(old_format)
266
repo = bzrdir.BzrDir.create_repository(self.get_url(), format=format)
267
self.assertEqual('A repository', repo)
269
def test_create_repository_shared(self):
270
old_format = bzrdir.BzrDirFormat.get_default_format()
271
repo = bzrdir.BzrDir.create_repository('.', shared=True)
272
self.assertTrue(repo.is_shared())
274
def test_create_repository_nonshared(self):
275
old_format = bzrdir.BzrDirFormat.get_default_format()
276
repo = bzrdir.BzrDir.create_repository('.')
277
self.assertFalse(repo.is_shared())
166
279
def test_create_repository_under_shared(self):
167
280
# an explicit create_repository always does so.
168
281
# we trust the format is right from the 'create_repository test'
169
old_format = bzrdir.BzrDirFormat.get_default_format()
170
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
172
self.make_repository('.', shared=True)
173
repo = bzrdir.BzrDir.create_repository(self.get_url('child'))
174
self.assertTrue(isinstance(repo, repository.Repository))
175
self.assertTrue(repo.bzrdir.root_transport.base.endswith('child/'))
177
bzrdir.BzrDirFormat.set_default_format(old_format)
282
format = bzrdir.format_registry.make_bzrdir('knit')
283
self.make_repository('.', shared=True, format=format)
284
repo = bzrdir.BzrDir.create_repository(self.get_url('child'),
286
self.assertTrue(isinstance(repo, repository.Repository))
287
self.assertTrue(repo.bzrdir.root_transport.base.endswith('child/'))
179
289
def test_create_branch_and_repo_uses_default(self):
180
290
format = SampleBzrDirFormat()
181
old_format = bzrdir.BzrDirFormat.get_default_format()
182
bzrdir.BzrDirFormat.set_default_format(format)
184
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url())
185
self.assertTrue(isinstance(branch, SampleBranch))
187
bzrdir.BzrDirFormat.set_default_format(old_format)
291
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url(),
293
self.assertTrue(isinstance(branch, SampleBranch))
189
295
def test_create_branch_and_repo_under_shared(self):
190
296
# creating a branch and repo in a shared repo uses the
191
297
# shared repository
192
old_format = bzrdir.BzrDirFormat.get_default_format()
193
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
195
self.make_repository('.', shared=True)
196
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'))
197
self.assertRaises(errors.NoRepositoryPresent,
198
branch.bzrdir.open_repository)
200
bzrdir.BzrDirFormat.set_default_format(old_format)
298
format = bzrdir.format_registry.make_bzrdir('knit')
299
self.make_repository('.', shared=True, format=format)
300
branch = bzrdir.BzrDir.create_branch_and_repo(
301
self.get_url('child'), format=format)
302
self.assertRaises(errors.NoRepositoryPresent,
303
branch.bzrdir.open_repository)
202
305
def test_create_branch_and_repo_under_shared_force_new(self):
203
306
# creating a branch and repo in a shared repo can be forced to
204
307
# make a new repo
205
old_format = bzrdir.BzrDirFormat.get_default_format()
206
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
208
self.make_repository('.', shared=True)
209
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'),
211
branch.bzrdir.open_repository()
213
bzrdir.BzrDirFormat.set_default_format(old_format)
308
format = bzrdir.format_registry.make_bzrdir('knit')
309
self.make_repository('.', shared=True, format=format)
310
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'),
313
branch.bzrdir.open_repository()
215
315
def test_create_standalone_working_tree(self):
216
316
format = SampleBzrDirFormat()
217
old_format = bzrdir.BzrDirFormat.get_default_format()
218
bzrdir.BzrDirFormat.set_default_format(format)
220
# note this is deliberately readonly, as this failure should
221
# occur before any writes.
222
self.assertRaises(errors.NotLocalUrl,
223
bzrdir.BzrDir.create_standalone_workingtree,
224
self.get_readonly_url())
225
tree = bzrdir.BzrDir.create_standalone_workingtree('.')
226
self.assertEqual('A tree', tree)
228
bzrdir.BzrDirFormat.set_default_format(old_format)
317
# note this is deliberately readonly, as this failure should
318
# occur before any writes.
319
self.assertRaises(errors.NotLocalUrl,
320
bzrdir.BzrDir.create_standalone_workingtree,
321
self.get_readonly_url(), format=format)
322
tree = bzrdir.BzrDir.create_standalone_workingtree('.',
324
self.assertEqual('A tree', tree)
230
326
def test_create_standalone_working_tree_under_shared_repo(self):
231
327
# create standalone working tree always makes a repo.
232
old_format = bzrdir.BzrDirFormat.get_default_format()
233
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
235
self.make_repository('.', shared=True)
236
# note this is deliberately readonly, as this failure should
237
# occur before any writes.
238
self.assertRaises(errors.NotLocalUrl,
239
bzrdir.BzrDir.create_standalone_workingtree,
240
self.get_readonly_url('child'))
241
tree = bzrdir.BzrDir.create_standalone_workingtree('child')
242
tree.bzrdir.open_repository()
244
bzrdir.BzrDirFormat.set_default_format(old_format)
328
format = bzrdir.format_registry.make_bzrdir('knit')
329
self.make_repository('.', shared=True, format=format)
330
# note this is deliberately readonly, as this failure should
331
# occur before any writes.
332
self.assertRaises(errors.NotLocalUrl,
333
bzrdir.BzrDir.create_standalone_workingtree,
334
self.get_readonly_url('child'), format=format)
335
tree = bzrdir.BzrDir.create_standalone_workingtree('child',
337
tree.bzrdir.open_repository()
246
339
def test_create_branch_convenience(self):
247
340
# outside a repo the default convenience output is a repo+branch_tree
248
old_format = bzrdir.BzrDirFormat.get_default_format()
249
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
251
branch = bzrdir.BzrDir.create_branch_convenience('.')
252
branch.bzrdir.open_workingtree()
253
branch.bzrdir.open_repository()
255
bzrdir.BzrDirFormat.set_default_format(old_format)
341
format = bzrdir.format_registry.make_bzrdir('knit')
342
branch = bzrdir.BzrDir.create_branch_convenience('.', format=format)
343
branch.bzrdir.open_workingtree()
344
branch.bzrdir.open_repository()
346
def test_create_branch_convenience_possible_transports(self):
347
"""Check that the optional 'possible_transports' is recognized"""
348
format = bzrdir.format_registry.make_bzrdir('knit')
349
t = self.get_transport()
350
branch = bzrdir.BzrDir.create_branch_convenience(
351
'.', format=format, possible_transports=[t])
352
branch.bzrdir.open_workingtree()
353
branch.bzrdir.open_repository()
257
355
def test_create_branch_convenience_root(self):
258
356
"""Creating a branch at the root of a fs should work."""
259
self.transport_server = MemoryServer
357
self.vfs_transport_factory = MemoryServer
260
358
# outside a repo the default convenience output is a repo+branch_tree
261
old_format = bzrdir.BzrDirFormat.get_default_format()
262
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
264
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url())
265
self.assertRaises(errors.NoWorkingTree,
266
branch.bzrdir.open_workingtree)
267
branch.bzrdir.open_repository()
269
bzrdir.BzrDirFormat.set_default_format(old_format)
359
format = bzrdir.format_registry.make_bzrdir('knit')
360
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
362
self.assertRaises(errors.NoWorkingTree,
363
branch.bzrdir.open_workingtree)
364
branch.bzrdir.open_repository()
271
366
def test_create_branch_convenience_under_shared_repo(self):
272
367
# inside a repo the default convenience output is a branch+ follow the
273
368
# repo tree policy
274
old_format = bzrdir.BzrDirFormat.get_default_format()
275
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
277
self.make_repository('.', shared=True)
278
branch = bzrdir.BzrDir.create_branch_convenience('child')
279
branch.bzrdir.open_workingtree()
280
self.assertRaises(errors.NoRepositoryPresent,
281
branch.bzrdir.open_repository)
283
bzrdir.BzrDirFormat.set_default_format(old_format)
369
format = bzrdir.format_registry.make_bzrdir('knit')
370
self.make_repository('.', shared=True, format=format)
371
branch = bzrdir.BzrDir.create_branch_convenience('child',
373
branch.bzrdir.open_workingtree()
374
self.assertRaises(errors.NoRepositoryPresent,
375
branch.bzrdir.open_repository)
285
377
def test_create_branch_convenience_under_shared_repo_force_no_tree(self):
286
378
# inside a repo the default convenience output is a branch+ follow the
287
379
# repo tree policy but we can override that
288
old_format = bzrdir.BzrDirFormat.get_default_format()
289
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
291
self.make_repository('.', shared=True)
292
branch = bzrdir.BzrDir.create_branch_convenience('child',
293
force_new_tree=False)
294
self.assertRaises(errors.NoWorkingTree,
295
branch.bzrdir.open_workingtree)
296
self.assertRaises(errors.NoRepositoryPresent,
297
branch.bzrdir.open_repository)
299
bzrdir.BzrDirFormat.set_default_format(old_format)
380
format = bzrdir.format_registry.make_bzrdir('knit')
381
self.make_repository('.', shared=True, format=format)
382
branch = bzrdir.BzrDir.create_branch_convenience('child',
383
force_new_tree=False, format=format)
384
self.assertRaises(errors.NoWorkingTree,
385
branch.bzrdir.open_workingtree)
386
self.assertRaises(errors.NoRepositoryPresent,
387
branch.bzrdir.open_repository)
301
389
def test_create_branch_convenience_under_shared_repo_no_tree_policy(self):
302
390
# inside a repo the default convenience output is a branch+ follow the
303
391
# repo tree policy
304
old_format = bzrdir.BzrDirFormat.get_default_format()
305
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
307
repo = self.make_repository('.', shared=True)
308
repo.set_make_working_trees(False)
309
branch = bzrdir.BzrDir.create_branch_convenience('child')
310
self.assertRaises(errors.NoWorkingTree,
311
branch.bzrdir.open_workingtree)
312
self.assertRaises(errors.NoRepositoryPresent,
313
branch.bzrdir.open_repository)
315
bzrdir.BzrDirFormat.set_default_format(old_format)
392
format = bzrdir.format_registry.make_bzrdir('knit')
393
repo = self.make_repository('.', shared=True, format=format)
394
repo.set_make_working_trees(False)
395
branch = bzrdir.BzrDir.create_branch_convenience('child',
397
self.assertRaises(errors.NoWorkingTree,
398
branch.bzrdir.open_workingtree)
399
self.assertRaises(errors.NoRepositoryPresent,
400
branch.bzrdir.open_repository)
317
402
def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self):
318
403
# inside a repo the default convenience output is a branch+ follow the
319
404
# repo tree policy but we can override that
320
old_format = bzrdir.BzrDirFormat.get_default_format()
321
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
323
repo = self.make_repository('.', shared=True)
324
repo.set_make_working_trees(False)
325
branch = bzrdir.BzrDir.create_branch_convenience('child',
327
branch.bzrdir.open_workingtree()
328
self.assertRaises(errors.NoRepositoryPresent,
329
branch.bzrdir.open_repository)
331
bzrdir.BzrDirFormat.set_default_format(old_format)
405
format = bzrdir.format_registry.make_bzrdir('knit')
406
repo = self.make_repository('.', shared=True, format=format)
407
repo.set_make_working_trees(False)
408
branch = bzrdir.BzrDir.create_branch_convenience('child',
409
force_new_tree=True, format=format)
410
branch.bzrdir.open_workingtree()
411
self.assertRaises(errors.NoRepositoryPresent,
412
branch.bzrdir.open_repository)
333
414
def test_create_branch_convenience_under_shared_repo_force_new_repo(self):
334
415
# inside a repo the default convenience output is overridable to give
335
416
# repo+branch+tree
336
old_format = bzrdir.BzrDirFormat.get_default_format()
337
bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
339
self.make_repository('.', shared=True)
340
branch = bzrdir.BzrDir.create_branch_convenience('child',
342
branch.bzrdir.open_repository()
343
branch.bzrdir.open_workingtree()
345
bzrdir.BzrDirFormat.set_default_format(old_format)
417
format = bzrdir.format_registry.make_bzrdir('knit')
418
self.make_repository('.', shared=True, format=format)
419
branch = bzrdir.BzrDir.create_branch_convenience('child',
420
force_new_repo=True, format=format)
421
branch.bzrdir.open_repository()
422
branch.bzrdir.open_workingtree()
348
425
class ChrootedTests(TestCaseWithTransport):
382
459
get_transport(self.get_readonly_url('g/p/q')))
383
460
self.assertEqual('g/p/q', relpath)
462
def test_open_containing_tree_or_branch(self):
463
def local_branch_path(branch):
464
return os.path.realpath(
465
urlutils.local_path_from_url(branch.base))
467
self.make_branch_and_tree('topdir')
468
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
470
self.assertEqual(os.path.realpath('topdir'),
471
os.path.realpath(tree.basedir))
472
self.assertEqual(os.path.realpath('topdir'),
473
local_branch_path(branch))
474
self.assertIs(tree.bzrdir, branch.bzrdir)
475
self.assertEqual('foo', relpath)
476
# opening from non-local should not return the tree
477
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
478
self.get_readonly_url('topdir/foo'))
479
self.assertEqual(None, tree)
480
self.assertEqual('foo', relpath)
482
self.make_branch('topdir/foo')
483
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
485
self.assertIs(tree, None)
486
self.assertEqual(os.path.realpath('topdir/foo'),
487
local_branch_path(branch))
488
self.assertEqual('', relpath)
490
def test_open_from_transport(self):
491
# transport pointing at bzrdir should give a bzrdir with root transport
492
# set to the given transport
493
control = bzrdir.BzrDir.create(self.get_url())
494
transport = get_transport(self.get_url())
495
opened_bzrdir = bzrdir.BzrDir.open_from_transport(transport)
496
self.assertEqual(transport.base, opened_bzrdir.root_transport.base)
497
self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir)
499
def test_open_from_transport_no_bzrdir(self):
500
transport = get_transport(self.get_url())
501
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
504
def test_open_from_transport_bzrdir_in_parent(self):
505
control = bzrdir.BzrDir.create(self.get_url())
506
transport = get_transport(self.get_url())
507
transport.mkdir('subdir')
508
transport = transport.clone('subdir')
509
self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
512
def test_sprout_recursive(self):
513
tree = self.make_branch_and_tree('tree1', format='dirstate-with-subtree')
514
sub_tree = self.make_branch_and_tree('tree1/subtree',
515
format='dirstate-with-subtree')
516
tree.add_reference(sub_tree)
517
self.build_tree(['tree1/subtree/file'])
519
tree.commit('Initial commit')
520
tree.bzrdir.sprout('tree2')
521
self.failUnlessExists('tree2/subtree/file')
523
def test_cloning_metadir(self):
524
"""Ensure that cloning metadir is suitable"""
525
bzrdir = self.make_bzrdir('bzrdir')
526
bzrdir.cloning_metadir()
527
branch = self.make_branch('branch', format='knit')
528
format = branch.bzrdir.cloning_metadir()
529
self.assertIsInstance(format.workingtree_format,
530
workingtree.WorkingTreeFormat3)
532
def test_sprout_recursive_treeless(self):
533
tree = self.make_branch_and_tree('tree1',
534
format='dirstate-with-subtree')
535
sub_tree = self.make_branch_and_tree('tree1/subtree',
536
format='dirstate-with-subtree')
537
tree.add_reference(sub_tree)
538
self.build_tree(['tree1/subtree/file'])
540
tree.commit('Initial commit')
541
tree.bzrdir.destroy_workingtree()
542
repo = self.make_repository('repo', shared=True,
543
format='dirstate-with-subtree')
544
repo.set_make_working_trees(False)
545
tree.bzrdir.sprout('repo/tree2')
546
self.failUnlessExists('repo/tree2/subtree')
547
self.failIfExists('repo/tree2/subtree/file')
386
550
class TestMeta1DirFormat(TestCaseWithTransport):
387
551
"""Tests specific to the meta1 dir format."""
592
775
result.open_branch()
593
776
result.open_repository()
778
def test_checkout_metadir(self):
779
# checkout_metadir has reasonable working tree format even when no
780
# working tree is present
781
self.make_branch('branch-knit2', format='dirstate-with-subtree')
782
my_bzrdir = bzrdir.BzrDir.open(self.get_url('branch-knit2'))
783
checkout_format = my_bzrdir.checkout_metadir()
784
self.assertIsInstance(checkout_format.workingtree_format,
785
workingtree.WorkingTreeFormat3)
788
class TestHTTPRedirectionLoop(object):
789
"""Test redirection loop between two http servers.
791
This MUST be used by daughter classes that also inherit from
792
TestCaseWithTwoWebservers.
794
We can't inherit directly from TestCaseWithTwoWebservers or the
795
test framework will try to create an instance which cannot
796
run, its implementation being incomplete.
799
# Should be defined by daughter classes to ensure redirection
800
# still use the same transport implementation (not currently
801
# enforced as it's a bit tricky to get right (see the FIXME
802
# in BzrDir.open_from_transport for the unique use case so
806
def create_transport_readonly_server(self):
807
return HTTPServerRedirecting()
809
def create_transport_secondary_server(self):
810
return HTTPServerRedirecting()
813
# Both servers redirect to each server creating a loop
814
super(TestHTTPRedirectionLoop, self).setUp()
815
# The redirections will point to the new server
816
self.new_server = self.get_readonly_server()
817
# The requests to the old server will be redirected
818
self.old_server = self.get_secondary_server()
819
# Configure the redirections
820
self.old_server.redirect_to(self.new_server.host, self.new_server.port)
821
self.new_server.redirect_to(self.old_server.host, self.old_server.port)
823
def _qualified_url(self, host, port):
824
return 'http+%s://%s:%s' % (self._qualifier, host, port)
827
# Starting from either server should loop
828
old_url = self._qualified_url(self.old_server.host,
829
self.old_server.port)
830
oldt = self._transport(old_url)
831
self.assertRaises(errors.NotBranchError,
832
bzrdir.BzrDir.open_from_transport, oldt)
833
new_url = self._qualified_url(self.new_server.host,
834
self.new_server.port)
835
newt = self._transport(new_url)
836
self.assertRaises(errors.NotBranchError,
837
bzrdir.BzrDir.open_from_transport, newt)
840
class TestHTTPRedirections_urllib(TestHTTPRedirectionLoop,
841
TestCaseWithTwoWebservers):
842
"""Tests redirections for urllib implementation"""
844
_qualifier = 'urllib'
845
_transport = HttpTransport_urllib
849
class TestHTTPRedirections_pycurl(TestWithTransport_pycurl,
850
TestHTTPRedirectionLoop,
851
TestCaseWithTwoWebservers):
852
"""Tests redirections for pycurl implementation"""
854
_qualifier = 'pycurl'