350
350
request.execute, 'subdir')
353
class TestSmartServerRequestBzrDirInitializeEx(tests.TestCaseWithMemoryTransport):
354
"""Basic tests for BzrDir.initialize_ex in the smart server.
356
The main unit tests in test_bzrdir exercise the API coprehensively.
359
def test_empty_dir(self):
360
"""Initializing an empty dir should succeed and do it."""
361
backing = self.get_transport()
362
request = smart.bzrdir.SmartServerRequestBzrDirInitializeEx(backing)
363
self.assertEqual(SmartServerResponse(()), request.execute('', 'True'))
364
made_dir = bzrdir.BzrDir.open_from_transport(backing)
365
# no branch, tree or repository is expected with the current
367
self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree)
368
self.assertRaises(errors.NotBranchError, made_dir.open_branch)
369
self.assertRaises(errors.NoRepositoryPresent, made_dir.open_repository)
371
def test_missing_dir(self):
372
"""Initializing a missing directory should fail like the bzrdir api."""
373
backing = self.get_transport()
374
request = smart.bzrdir.SmartServerRequestBzrDirInitializeEx(backing)
375
self.assertRaises(errors.NoSuchFile, request.execute, 'subdir/dir', 'False')
377
def test_initialized_dir(self):
378
"""Initializing an extant dirctory should fail like the bzrdir api."""
379
backing = self.get_transport()
380
request = smart.bzrdir.SmartServerRequestBzrDirInitializeEx(backing)
381
self.make_bzrdir('subdir')
382
self.assertRaises(errors.FileExists, request.execute, 'subdir', 'False')
353
385
class TestSmartServerRequestOpenBranch(TestCaseWithChrootedTransport):
355
387
def test_no_branch(self):
1479
1511
smart.bzrdir.SmartServerRequestFindRepositoryV2)
1480
1512
self.assertHandlerEqual('BzrDirFormat.initialize',
1481
1513
smart.bzrdir.SmartServerRequestInitializeBzrDir)
1514
self.assertHandlerEqual('BzrDirFormat.initialize_ex',
1515
smart.bzrdir.SmartServerRequestBzrDirInitializeEx)
1482
1516
self.assertHandlerEqual('BzrDir.cloning_metadir',
1483
1517
smart.bzrdir.SmartServerBzrDirRequestCloningMetaDir)
1484
1518
self.assertHandlerEqual('BzrDir.get_config_file',