/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Jelmer Vernooij
  • Date: 2009-04-03 17:36:43 UTC
  • mfrom: (4222.2.9 ui-username)
  • mto: This revision was merged to the branch mainline in revision 4284.
  • Revision ID: jelmer@samba.org-20090403173643-xcf89aq1bn3yxipt
Merge new username ui call.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
from bzrlib.revision import NULL_REVISION
54
54
from bzrlib.smart import server, medium
55
55
from bzrlib.smart.client import _SmartClient
 
56
from bzrlib.smart.repository import SmartServerRepositoryGetParentMap
56
57
from bzrlib.tests import (
57
58
    condition_isinstance,
58
59
    split_suite_by_condition,
998
999
        result = branch.get_stacked_on_url()
999
1000
        self.assertEqual('../base', result)
1000
1001
        client.finished_test()
1001
 
        # it's in the fallback list both for the RemoteRepository and its vfs
1002
 
        # repository
 
1002
        # it's in the fallback list both for the RemoteRepository.
1003
1003
        self.assertEqual(1, len(branch.repository._fallback_repositories))
1004
 
        self.assertEqual(1,
1005
 
            len(branch.repository._real_repository._fallback_repositories))
 
1004
        # And we haven't had to construct a real repository.
 
1005
        self.assertEqual(None, branch.repository._real_repository)
1006
1006
 
1007
1007
 
1008
1008
class TestBranchSetLastRevision(RemoteBranchTestCase):
1332
1332
        self.assertEqual('rejection message', err.msg)
1333
1333
 
1334
1334
 
1335
 
class TestBranchControlGetBranchConf(tests.TestCaseWithMemoryTransport):
 
1335
class TestBranchControlGetBranchConf(RemoteBranchTestCase):
1336
1336
    """Getting the branch configuration should use an abstract method not vfs.
1337
1337
    """
1338
1338
 
1339
1339
    def test_get_branch_conf(self):
1340
 
        raise tests.KnownFailure('branch.conf is not retrieved by get_config_file')
1341
 
        ## # We should see that branch.get_config() does a single rpc to get the
1342
 
        ## # remote configuration file, abstracting away where that is stored on
1343
 
        ## # the server.  However at the moment it always falls back to using the
1344
 
        ## # vfs, and this would need some changes in config.py.
 
1340
        # We should see that branch.get_config() does a single rpc to get the
 
1341
        # remote configuration file, abstracting away where that is stored on
 
1342
        # the server.  However at the moment it always falls back to using the
 
1343
        # vfs, and this would need some changes in config.py.
1345
1344
 
1346
 
        ## # in an empty branch we decode the response properly
1347
 
        ## client = FakeClient([(('ok', ), '# config file body')], self.get_url())
1348
 
        ## # we need to make a real branch because the remote_branch.control_files
1349
 
        ## # will trigger _ensure_real.
1350
 
        ## branch = self.make_branch('quack')
1351
 
        ## transport = branch.bzrdir.root_transport
1352
 
        ## # we do not want bzrdir to make any remote calls
1353
 
        ## bzrdir = RemoteBzrDir(transport, _client=False)
1354
 
        ## branch = RemoteBranch(bzrdir, None, _client=client)
1355
 
        ## config = branch.get_config()
1356
 
        ## self.assertEqual(
1357
 
        ##     [('call_expecting_body', 'Branch.get_config_file', ('quack/',))],
1358
 
        ##     client._calls)
 
1345
        # in an empty branch we decode the response properly
 
1346
        client = FakeClient()
 
1347
        client.add_expected_call(
 
1348
            'Branch.get_stacked_on_url', ('memory:///',),
 
1349
            'error', ('NotStacked',),)
 
1350
        client.add_success_response_with_body('# config file body', 'ok')
 
1351
        transport = MemoryTransport()
 
1352
        branch = self.make_remote_branch(transport, client)
 
1353
        config = branch.get_config()
 
1354
        config.has_explicit_nickname()
 
1355
        self.assertEqual(
 
1356
            [('call', 'Branch.get_stacked_on_url', ('memory:///',)),
 
1357
             ('call_expecting_body', 'Branch.get_config_file', ('memory:///',))],
 
1358
            client._calls)
1359
1359
 
1360
1360
 
1361
1361
class TestBranchLockWrite(RemoteBranchTestCase):
1673
1673
                'more-missing']))
1674
1674
        self.assertLength(1, self.hpss_calls)
1675
1675
 
 
1676
    def disableExtraResults(self):
 
1677
        old_flag = SmartServerRepositoryGetParentMap.no_extra_results
 
1678
        SmartServerRepositoryGetParentMap.no_extra_results = True
 
1679
        def reset_values():
 
1680
            SmartServerRepositoryGetParentMap.no_extra_results = old_flag
 
1681
        self.addCleanup(reset_values)
 
1682
 
 
1683
    def test_null_cached_missing_and_stop_key(self):
 
1684
        self.setup_smart_server_with_call_log()
 
1685
        # Make a branch with a single revision.
 
1686
        builder = self.make_branch_builder('foo')
 
1687
        builder.start_series()
 
1688
        builder.build_snapshot('first', None, [
 
1689
            ('add', ('', 'root-id', 'directory', ''))])
 
1690
        builder.finish_series()
 
1691
        branch = builder.get_branch()
 
1692
        repo = branch.repository
 
1693
        self.assertIsInstance(repo, RemoteRepository)
 
1694
        # Stop the server from sending extra results.
 
1695
        self.disableExtraResults()
 
1696
        repo.lock_read()
 
1697
        self.addCleanup(repo.unlock)
 
1698
        self.reset_smart_call_log()
 
1699
        graph = repo.get_graph()
 
1700
        # Query for 'first' and 'null:'.  Because 'null:' is a parent of
 
1701
        # 'first' it will be a candidate for the stop_keys of subsequent
 
1702
        # requests, and because 'null:' was queried but not returned it will be
 
1703
        # cached as missing.
 
1704
        self.assertEqual({'first': ('null:',)},
 
1705
            graph.get_parent_map(['first', 'null:']))
 
1706
        # Now query for another key.  This request will pass along a recipe of
 
1707
        # start and stop keys describing the already cached results, and this
 
1708
        # recipe's revision count must be correct (or else it will trigger an
 
1709
        # error from the server).
 
1710
        self.assertEqual({}, graph.get_parent_map(['another-key']))
 
1711
        # This assertion guards against disableExtraResults silently failing to
 
1712
        # work, thus invalidating the test.
 
1713
        self.assertLength(2, self.hpss_calls)
 
1714
 
1676
1715
    def test_get_parent_map_gets_ghosts_from_result(self):
1677
1716
        # asking for a revision should negatively cache close ghosts in its
1678
1717
        # ancestry.