~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Robert Collins
  • Date: 2009-04-24 00:45:11 UTC
  • mto: This revision was merged to the branch mainline in revision 4304.
  • Revision ID: robertc@robertcollins.net-20090424004511-8oszlwmvehlqwrla
Start building up a BzrDir.initialize_ex verb for the smart server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
            request.execute, 'subdir')
351
351
 
352
352
 
 
353
class TestSmartServerRequestBzrDirInitializeEx(tests.TestCaseWithMemoryTransport):
 
354
    """Basic tests for BzrDir.initialize_ex in the smart server.
 
355
 
 
356
    The main unit tests in test_bzrdir exercise the API coprehensively.
 
357
    """
 
358
 
 
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
 
366
        # default formart.
 
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)
 
370
 
 
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')
 
376
 
 
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')
 
383
 
 
384
 
353
385
class TestSmartServerRequestOpenBranch(TestCaseWithChrootedTransport):
354
386
 
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',