359
359
a given client_base and transport_base.
361
361
client_medium = medium.SmartClientMedium(client_base)
362
transport = get_transport(transport_base)
363
result = client_medium.remote_path_from_transport(transport)
362
t = transport.get_transport(transport_base)
363
result = client_medium.remote_path_from_transport(t)
364
364
self.assertEqual(expected, result)
366
366
def test_remote_path_from_transport(self):
377
377
a given transport_base and relpath of that transport. (Note that
378
378
HttpTransportBase is a subclass of SmartClientMedium)
380
base_transport = get_transport(transport_base)
380
base_transport = transport.get_transport(transport_base)
381
381
client_medium = base_transport.get_smart_medium()
382
382
cloned_transport = base_transport.clone(relpath)
383
383
result = client_medium.remote_path_from_transport(cloned_transport)
609
609
# _get_tree_branch is a form of open_branch, but it should only ask for
610
610
# branch opening, not any other network requests.
612
def open_branch(name=None):
613
613
calls.append("Called")
614
614
return "a-branch"
615
615
transport = MemoryTransport()
1618
1618
def test_get_multi_line_branch_conf(self):
1619
1619
# Make sure that multiple-line branch.conf files are supported
1621
# https://bugs.edge.launchpad.net/bzr/+bug/354075
1621
# https://bugs.launchpad.net/bzr/+bug/354075
1622
1622
client = FakeClient()
1623
1623
client.add_expected_call(
1624
1624
'Branch.get_stacked_on_url', ('memory:///',),
1652
1652
branch.unlock()
1653
1653
self.assertFinished(client)
1655
def test_set_option_with_dict(self):
1656
client = FakeClient()
1657
client.add_expected_call(
1658
'Branch.get_stacked_on_url', ('memory:///',),
1659
'error', ('NotStacked',),)
1660
client.add_expected_call(
1661
'Branch.lock_write', ('memory:///', '', ''),
1662
'success', ('ok', 'branch token', 'repo token'))
1663
encoded_dict_value = 'd5:ascii1:a11:unicode \xe2\x8c\x9a3:\xe2\x80\xbde'
1664
client.add_expected_call(
1665
'Branch.set_config_option_dict', ('memory:///', 'branch token',
1666
'repo token', encoded_dict_value, 'foo', ''),
1668
client.add_expected_call(
1669
'Branch.unlock', ('memory:///', 'branch token', 'repo token'),
1671
transport = MemoryTransport()
1672
branch = self.make_remote_branch(transport, client)
1674
config = branch._get_config()
1676
{'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'},
1679
self.assertFinished(client)
1655
1681
def test_backwards_compat_set_option(self):
1656
1682
self.setup_smart_server_with_call_log()
1657
1683
branch = self.make_branch('.')
1664
1690
self.assertLength(10, self.hpss_calls)
1665
1691
self.assertEqual('value', branch._get_config().get_option('name'))
1693
def test_backwards_compat_set_option_with_dict(self):
1694
self.setup_smart_server_with_call_log()
1695
branch = self.make_branch('.')
1696
verb = 'Branch.set_config_option_dict'
1697
self.disable_verb(verb)
1699
self.addCleanup(branch.unlock)
1700
self.reset_smart_call_log()
1701
config = branch._get_config()
1702
value_dict = {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'}
1703
config.set_option(value_dict, 'name')
1704
self.assertLength(10, self.hpss_calls)
1705
self.assertEqual(value_dict, branch._get_config().get_option('name'))
1668
1708
class TestBranchLockWrite(RemoteBranchTestCase):
2301
2342
transport_path = 'quack'
2302
2343
repo, client = self.setup_fake_client_and_repository(transport_path)
2303
2344
client.add_success_response('ok', 'a token')
2304
result = repo.lock_write()
2345
token = repo.lock_write().repository_token
2305
2346
self.assertEqual(
2306
2347
[('call', 'Repository.lock_write', ('quack/', ''))],
2308
self.assertEqual('a token', result)
2349
self.assertEqual('a token', token)
2310
2351
def test_lock_write_already_locked(self):
2311
2352
transport_path = 'quack'