~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-07-16 20:52:54 UTC
  • mfrom: (5193.5.9 cleanup)
  • Revision ID: pqm@pqm.ubuntu.com-20100716205254-j0m65wckb90rj54w
(vila) Cleanup some bogus rest constructs in the doc. (Vincent Ladeuil)

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,
89
89
        self.transport = self.get_transport()
90
90
        # make a branch that can be opened over the smart transport
91
91
        self.local_wt = BzrDir.create_standalone_workingtree('.')
92
 
 
93
 
    def tearDown(self):
94
 
        self.transport.disconnect()
95
 
        tests.TestCaseWithTransport.tearDown(self)
 
92
        self.addCleanup(self.transport.disconnect)
96
93
 
97
94
    def test_create_remote_bzrdir(self):
98
95
        b = remote.RemoteBzrDir(self.transport, remote.RemoteBzrDirFormat())
359
356
        a given client_base and transport_base.
360
357
        """
361
358
        client_medium = medium.SmartClientMedium(client_base)
362
 
        transport = get_transport(transport_base)
363
 
        result = client_medium.remote_path_from_transport(transport)
 
359
        t = transport.get_transport(transport_base)
 
360
        result = client_medium.remote_path_from_transport(t)
364
361
        self.assertEqual(expected, result)
365
362
 
366
363
    def test_remote_path_from_transport(self):
377
374
        a given transport_base and relpath of that transport.  (Note that
378
375
        HttpTransportBase is a subclass of SmartClientMedium)
379
376
        """
380
 
        base_transport = get_transport(transport_base)
 
377
        base_transport = transport.get_transport(transport_base)
381
378
        client_medium = base_transport.get_smart_medium()
382
379
        cloned_transport = base_transport.clone(relpath)
383
380
        result = client_medium.remote_path_from_transport(cloned_transport)
609
606
        # _get_tree_branch is a form of open_branch, but it should only ask for
610
607
        # branch opening, not any other network requests.
611
608
        calls = []
612
 
        def open_branch():
 
609
        def open_branch(name=None):
613
610
            calls.append("Called")
614
611
            return "a-branch"
615
612
        transport = MemoryTransport()
1618
1615
    def test_get_multi_line_branch_conf(self):
1619
1616
        # Make sure that multiple-line branch.conf files are supported
1620
1617
        #
1621
 
        # https://bugs.edge.launchpad.net/bzr/+bug/354075
 
1618
        # https://bugs.launchpad.net/bzr/+bug/354075
1622
1619
        client = FakeClient()
1623
1620
        client.add_expected_call(
1624
1621
            'Branch.get_stacked_on_url', ('memory:///',),
1652
1649
        branch.unlock()
1653
1650
        self.assertFinished(client)
1654
1651
 
 
1652
    def test_set_option_with_dict(self):
 
1653
        client = FakeClient()
 
1654
        client.add_expected_call(
 
1655
            'Branch.get_stacked_on_url', ('memory:///',),
 
1656
            'error', ('NotStacked',),)
 
1657
        client.add_expected_call(
 
1658
            'Branch.lock_write', ('memory:///', '', ''),
 
1659
            'success', ('ok', 'branch token', 'repo token'))
 
1660
        encoded_dict_value = 'd5:ascii1:a11:unicode \xe2\x8c\x9a3:\xe2\x80\xbde'
 
1661
        client.add_expected_call(
 
1662
            'Branch.set_config_option_dict', ('memory:///', 'branch token',
 
1663
            'repo token', encoded_dict_value, 'foo', ''),
 
1664
            'success', ())
 
1665
        client.add_expected_call(
 
1666
            'Branch.unlock', ('memory:///', 'branch token', 'repo token'),
 
1667
            'success', ('ok',))
 
1668
        transport = MemoryTransport()
 
1669
        branch = self.make_remote_branch(transport, client)
 
1670
        branch.lock_write()
 
1671
        config = branch._get_config()
 
1672
        config.set_option(
 
1673
            {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'},
 
1674
            'foo')
 
1675
        branch.unlock()
 
1676
        self.assertFinished(client)
 
1677
 
1655
1678
    def test_backwards_compat_set_option(self):
1656
1679
        self.setup_smart_server_with_call_log()
1657
1680
        branch = self.make_branch('.')
1664
1687
        self.assertLength(10, self.hpss_calls)
1665
1688
        self.assertEqual('value', branch._get_config().get_option('name'))
1666
1689
 
 
1690
    def test_backwards_compat_set_option_with_dict(self):
 
1691
        self.setup_smart_server_with_call_log()
 
1692
        branch = self.make_branch('.')
 
1693
        verb = 'Branch.set_config_option_dict'
 
1694
        self.disable_verb(verb)
 
1695
        branch.lock_write()
 
1696
        self.addCleanup(branch.unlock)
 
1697
        self.reset_smart_call_log()
 
1698
        config = branch._get_config()
 
1699
        value_dict = {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'}
 
1700
        config.set_option(value_dict, 'name')
 
1701
        self.assertLength(10, self.hpss_calls)
 
1702
        self.assertEqual(value_dict, branch._get_config().get_option('name'))
 
1703
 
1667
1704
 
1668
1705
class TestBranchLockWrite(RemoteBranchTestCase):
1669
1706
 
2257
2294
        self.setup_smart_server_with_call_log()
2258
2295
        tree = self.make_branch_and_memory_tree('.')
2259
2296
        tree.lock_write()
 
2297
        tree.add('')
2260
2298
        rev1 = tree.commit('First')
2261
2299
        rev2 = tree.commit('Second')
2262
2300
        tree.unlock()