/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Robert Collins
  • Date: 2009-03-06 03:55:27 UTC
  • mto: (4086.1.1 hpss-integration)
  • mto: This revision was merged to the branch mainline in revision 4087.
  • Revision ID: robertc@robertcollins.net-20090306035527-sm1gsd3nh3f2mxpa
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
364
364
            request.execute('reference'))
365
365
 
366
366
 
 
367
class TestSmartServerRequestOpenBranchV2(TestCaseWithChrootedTransport):
 
368
 
 
369
    def test_no_branch(self):
 
370
        """When there is no branch, ('nobranch', ) is returned."""
 
371
        backing = self.get_transport()
 
372
        self.make_bzrdir('.')
 
373
        request = smart.bzrdir.SmartServerRequestOpenBranchV2(backing)
 
374
        self.assertEqual(SmartServerResponse(('nobranch', )),
 
375
            request.execute(''))
 
376
 
 
377
    def test_branch(self):
 
378
        """When there is a branch, 'ok' is returned."""
 
379
        backing = self.get_transport()
 
380
        expected = self.make_branch('.')._format.network_name()
 
381
        request = smart.bzrdir.SmartServerRequestOpenBranchV2(backing)
 
382
        self.assertEqual(SuccessfulSmartServerResponse(('branch', expected)),
 
383
            request.execute(''))
 
384
 
 
385
    def test_branch_reference(self):
 
386
        """When there is a branch reference, the reference URL is returned."""
 
387
        backing = self.get_transport()
 
388
        request = smart.bzrdir.SmartServerRequestOpenBranchV2(backing)
 
389
        branch = self.make_branch('branch')
 
390
        checkout = branch.create_checkout('reference',lightweight=True)
 
391
        reference_url = BranchReferenceFormat().get_reference(checkout.bzrdir)
 
392
        self.assertFileEqual(reference_url, 'reference/.bzr/branch/location')
 
393
        self.assertEqual(SuccessfulSmartServerResponse(('ref', reference_url)),
 
394
            request.execute('reference'))
 
395
 
 
396
 
367
397
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithMemoryTransport):
368
398
 
369
399
    def test_empty(self):
696
726
            response)
697
727
 
698
728
 
 
729
class TestSmartServerBranchRequestGetTagsBytes(tests.TestCaseWithMemoryTransport):
 
730
# Only called when the branch format and tags match [yay factory
 
731
# methods] so only need to test straight forward cases.
 
732
 
 
733
    def test_get_bytes(self):
 
734
        base_branch = self.make_branch('base')
 
735
        request = smart.branch.SmartServerBranchGetTagsBytes(
 
736
            self.get_transport())
 
737
        response = request.execute('base')
 
738
        self.assertEquals(
 
739
            SuccessfulSmartServerResponse(('',)), response)
 
740
 
 
741
 
699
742
class TestSmartServerBranchRequestGetStackedOnURL(tests.TestCaseWithMemoryTransport):
700
743
 
701
744
    def test_get_stacked_on_url(self):
1209
1252
            smart.request.request_handlers.get('Branch.get_parent'),
1210
1253
            smart.branch.SmartServerBranchGetParent)
1211
1254
        self.assertEqual(
 
1255
            smart.request.request_handlers.get('Branch.get_tags_bytes'),
 
1256
            smart.branch.SmartServerBranchGetTagsBytes)
 
1257
        self.assertEqual(
1212
1258
            smart.request.request_handlers.get('Branch.lock_write'),
1213
1259
            smart.branch.SmartServerBranchRequestLockWrite)
1214
1260
        self.assertEqual(
1242
1288
            smart.request.request_handlers.get('BzrDir.open_branch'),
1243
1289
            smart.bzrdir.SmartServerRequestOpenBranch)
1244
1290
        self.assertEqual(
 
1291
            smart.request.request_handlers.get('BzrDir.open_branchV2'),
 
1292
            smart.bzrdir.SmartServerRequestOpenBranchV2)
 
1293
        self.assertEqual(
1245
1294
            smart.request.request_handlers.get('PackRepository.autopack'),
1246
1295
            smart.packrepository.SmartServerPackRepositoryAutopack)
1247
1296
        self.assertEqual(