~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Martin Pool
  • Date: 2010-08-13 08:09:53 UTC
  • mto: (5050.17.6 2.2)
  • mto: This revision was merged to the branch mainline in revision 5379.
  • Revision ID: mbp@sourcefrog.net-20100813080953-c00cm9l3qgu2flj9
Remove spuriously-resurrected test

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    remote,
39
39
    repository,
40
40
    tests,
 
41
    transport,
41
42
    treebuilder,
42
43
    urlutils,
43
44
    versionedfile,
63
64
    multiply_tests,
64
65
    test_server,
65
66
    )
66
 
from bzrlib.transport import get_transport
67
67
from bzrlib.transport.memory import MemoryTransport
68
68
from bzrlib.transport.remote import (
69
69
    RemoteTransport,
359
359
        a given client_base and transport_base.
360
360
        """
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)
365
365
 
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)
379
379
        """
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.
611
611
        calls = []
612
 
        def open_branch():
 
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
1620
1620
        #
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)
1654
1654
 
 
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', ''),
 
1667
            'success', ())
 
1668
        client.add_expected_call(
 
1669
            'Branch.unlock', ('memory:///', 'branch token', 'repo token'),
 
1670
            'success', ('ok',))
 
1671
        transport = MemoryTransport()
 
1672
        branch = self.make_remote_branch(transport, client)
 
1673
        branch.lock_write()
 
1674
        config = branch._get_config()
 
1675
        config.set_option(
 
1676
            {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'},
 
1677
            'foo')
 
1678
        branch.unlock()
 
1679
        self.assertFinished(client)
 
1680
 
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'))
1666
1692
 
 
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)
 
1698
        branch.lock_write()
 
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'))
 
1706
 
1667
1707
 
1668
1708
class TestBranchLockWrite(RemoteBranchTestCase):
1669
1709
 
2257
2297
        self.setup_smart_server_with_call_log()
2258
2298
        tree = self.make_branch_and_memory_tree('.')
2259
2299
        tree.lock_write()
 
2300
        tree.add('')
2260
2301
        rev1 = tree.commit('First')
2261
2302
        rev2 = tree.commit('Second')
2262
2303
        tree.unlock()
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/', ''))],
2307
2348
            client._calls)
2308
 
        self.assertEqual('a token', result)
 
2349
        self.assertEqual('a token', token)
2309
2350
 
2310
2351
    def test_lock_write_already_locked(self):
2311
2352
        transport_path = 'quack'