1038
1038
return RemoteBranch(bzrdir, repo, _client=client, format=format)
1041
class TestBranchBreakLock(RemoteBranchTestCase):
1043
def test_break_lock(self):
1044
transport_path = 'quack'
1045
transport = MemoryTransport()
1046
client = FakeClient(transport.base)
1047
client.add_expected_call(
1048
'Branch.get_stacked_on_url', ('quack/',),
1049
'error', ('NotStacked',))
1050
client.add_expected_call(
1051
'Branch.break_lock', ('quack/',),
1053
transport.mkdir('quack')
1054
transport = transport.clone('quack')
1055
branch = self.make_remote_branch(transport, client)
1057
self.assertFinished(client)
1041
1060
class TestBranchGetPhysicalLockStatus(RemoteBranchTestCase):
1043
1062
def test_get_physical_lock_status_yes(self):
1994
2013
self.assertFinished(client)
2016
class TestBranchRevisionIdToRevno(RemoteBranchTestCase):
2018
def test_simple(self):
2019
transport = MemoryTransport()
2020
client = FakeClient(transport.base)
2021
client.add_expected_call(
2022
'Branch.get_stacked_on_url', ('quack/',),
2023
'error', ('NotStacked',),)
2024
client.add_expected_call(
2025
'Branch.revision_id_to_revno', ('quack/', 'null:'),
2026
'success', ('ok', '0',),)
2027
client.add_expected_call(
2028
'Branch.revision_id_to_revno', ('quack/', 'unknown'),
2029
'error', ('NoSuchRevision', 'unknown',),)
2030
transport.mkdir('quack')
2031
transport = transport.clone('quack')
2032
branch = self.make_remote_branch(transport, client)
2033
self.assertEquals(0, branch.revision_id_to_revno('null:'))
2034
self.assertRaises(errors.NoSuchRevision,
2035
branch.revision_id_to_revno, 'unknown')
2036
self.assertFinished(client)
2038
def test_dotted(self):
2039
transport = MemoryTransport()
2040
client = FakeClient(transport.base)
2041
client.add_expected_call(
2042
'Branch.get_stacked_on_url', ('quack/',),
2043
'error', ('NotStacked',),)
2044
client.add_expected_call(
2045
'Branch.revision_id_to_revno', ('quack/', 'null:'),
2046
'success', ('ok', '0',),)
2047
client.add_expected_call(
2048
'Branch.revision_id_to_revno', ('quack/', 'unknown'),
2049
'error', ('NoSuchRevision', 'unknown',),)
2050
transport.mkdir('quack')
2051
transport = transport.clone('quack')
2052
branch = self.make_remote_branch(transport, client)
2053
self.assertEquals((0, ), branch.revision_id_to_dotted_revno('null:'))
2054
self.assertRaises(errors.NoSuchRevision,
2055
branch.revision_id_to_dotted_revno, 'unknown')
2056
self.assertFinished(client)
1997
2059
class TestBzrDirGetSetConfig(RemoteBzrDirTestCase):
1999
2061
def test__get_config(self):
2156
2218
remote_repo_format.get_format_description())
2221
class TestRepositoryAllRevisionIds(TestRemoteRepository):
2223
def test_empty(self):
2224
transport_path = 'quack'
2225
repo, client = self.setup_fake_client_and_repository(transport_path)
2226
client.add_success_response_with_body('', 'ok')
2227
self.assertEquals([], repo.all_revision_ids())
2229
[('call_expecting_body', 'Repository.all_revision_ids',
2233
def test_with_some_content(self):
2234
transport_path = 'quack'
2235
repo, client = self.setup_fake_client_and_repository(transport_path)
2236
client.add_success_response_with_body(
2237
'rev1\nrev2\nanotherrev\n', 'ok')
2238
self.assertEquals(["rev1", "rev2", "anotherrev"],
2239
repo.all_revision_ids())
2241
[('call_expecting_body', 'Repository.all_revision_ids',
2159
2246
class TestRepositoryGatherStats(TestRemoteRepository):
2161
2248
def test_revid_none(self):
2304
class TestRepositoryBreakLock(TestRemoteRepository):
2306
def test_break_lock(self):
2307
transport_path = 'quack'
2308
repo, client = self.setup_fake_client_and_repository(transport_path)
2309
client.add_success_response('ok')
2312
[('call', 'Repository.break_lock', ('quack/',))],
2217
2316
class TestRepositoryGetGraph(TestRemoteRepository):
2219
2318
def test_get_graph(self):
3730
3829
# interpretation
3731
3830
self.make_master_and_checkout('mas~ter', 'checkout')
3732
3831
self.assertUpdateSucceeds(self.bound_location.replace('%2E', '~', 1))
3834
class TestWithCustomErrorHandler(RemoteBranchTestCase):
3836
def test_no_context(self):
3837
class OutOfCoffee(errors.BzrError):
3838
"""A dummy exception for testing."""
3840
def __init__(self, urgency):
3841
self.urgency = urgency
3842
remote.no_context_error_translators.register("OutOfCoffee",
3843
lambda err: OutOfCoffee(err.error_args[0]))
3844
transport = MemoryTransport()
3845
client = FakeClient(transport.base)
3846
client.add_expected_call(
3847
'Branch.get_stacked_on_url', ('quack/',),
3848
'error', ('NotStacked',))
3849
client.add_expected_call(
3850
'Branch.last_revision_info',
3852
'error', ('OutOfCoffee', 'low'))
3853
transport.mkdir('quack')
3854
transport = transport.clone('quack')
3855
branch = self.make_remote_branch(transport, client)
3856
self.assertRaises(OutOfCoffee, branch.last_revision_info)
3857
self.assertFinished(client)
3859
def test_with_context(self):
3860
class OutOfTea(errors.BzrError):
3861
def __init__(self, branch, urgency):
3862
self.branch = branch
3863
self.urgency = urgency
3864
remote.error_translators.register("OutOfTea",
3865
lambda err, find, path: OutOfTea(err.error_args[0],
3867
transport = MemoryTransport()
3868
client = FakeClient(transport.base)
3869
client.add_expected_call(
3870
'Branch.get_stacked_on_url', ('quack/',),
3871
'error', ('NotStacked',))
3872
client.add_expected_call(
3873
'Branch.last_revision_info',
3875
'error', ('OutOfTea', 'low'))
3876
transport.mkdir('quack')
3877
transport = transport.clone('quack')
3878
branch = self.make_remote_branch(transport, client)
3879
self.assertRaises(OutOfTea, branch.last_revision_info)
3880
self.assertFinished(client)