364
364
request.execute('reference'))
367
class TestSmartServerRequestOpenBranchV2(TestCaseWithChrootedTransport):
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', )),
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)),
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'))
367
397
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithMemoryTransport):
369
399
def test_empty(self):
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.
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')
739
SuccessfulSmartServerResponse(('',)), response)
699
742
class TestSmartServerBranchRequestGetStackedOnURL(tests.TestCaseWithMemoryTransport):
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)
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)
1245
1294
smart.request.request_handlers.get('PackRepository.autopack'),
1246
1295
smart.packrepository.SmartServerPackRepositoryAutopack)
1247
1296
self.assertEqual(