/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: John Arbash Meinel
  • Date: 2009-10-15 20:04:37 UTC
  • mfrom: (4748 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4752.
  • Revision ID: john@arbash-meinel.com-20091015200437-4wweb0t6uzspvv84
Bring in bzr.dev 4748, resolve conflict, update NEWS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
474
474
        self.assertFinished(client)
475
475
 
476
476
 
 
477
class TestBzrDirOpen(TestRemote):
 
478
 
 
479
    def make_fake_client_and_transport(self, path='quack'):
 
480
        transport = MemoryTransport()
 
481
        transport.mkdir(path)
 
482
        transport = transport.clone(path)
 
483
        client = FakeClient(transport.base)
 
484
        return client, transport
 
485
 
 
486
    def test_absent(self):
 
487
        client, transport = self.make_fake_client_and_transport()
 
488
        client.add_expected_call(
 
489
            'BzrDir.open_2.1', ('quack/',), 'success', ('no',))
 
490
        self.assertRaises(errors.NotBranchError, RemoteBzrDir, transport,
 
491
                remote.RemoteBzrDirFormat(), _client=client, _force_probe=True)
 
492
        self.assertFinished(client)
 
493
 
 
494
    def test_present_without_workingtree(self):
 
495
        client, transport = self.make_fake_client_and_transport()
 
496
        client.add_expected_call(
 
497
            'BzrDir.open_2.1', ('quack/',), 'success', ('yes', 'no'))
 
498
        bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
499
            _client=client, _force_probe=True)
 
500
        self.assertIsInstance(bd, RemoteBzrDir)
 
501
        self.assertFalse(bd.has_workingtree())
 
502
        self.assertRaises(errors.NoWorkingTree, bd.open_workingtree)
 
503
        self.assertFinished(client)
 
504
 
 
505
    def test_present_with_workingtree(self):
 
506
        client, transport = self.make_fake_client_and_transport()
 
507
        client.add_expected_call(
 
508
            'BzrDir.open_2.1', ('quack/',), 'success', ('yes', 'yes'))
 
509
        bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
510
            _client=client, _force_probe=True)
 
511
        self.assertIsInstance(bd, RemoteBzrDir)
 
512
        self.assertTrue(bd.has_workingtree())
 
513
        self.assertRaises(errors.NotLocalUrl, bd.open_workingtree)
 
514
        self.assertFinished(client)
 
515
 
 
516
    def test_backwards_compat(self):
 
517
        client, transport = self.make_fake_client_and_transport()
 
518
        client.add_expected_call(
 
519
            'BzrDir.open_2.1', ('quack/',), 'unknown', ('BzrDir.open_2.1',))
 
520
        client.add_expected_call(
 
521
            'BzrDir.open', ('quack/',), 'success', ('yes',))
 
522
        bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
523
            _client=client, _force_probe=True)
 
524
        self.assertIsInstance(bd, RemoteBzrDir)
 
525
        self.assertFinished(client)
 
526
 
 
527
 
477
528
class TestBzrDirOpenBranch(TestRemote):
478
529
 
479
530
    def test_backwards_compat(self):
2150
2201
            repo.get_rev_id_for_revno, 5, (42, 'rev-foo'))
2151
2202
        self.assertFinished(client)
2152
2203
 
 
2204
    def test_branch_fallback_locking(self):
 
2205
        """RemoteBranch.get_rev_id takes a read lock, and tries to call the
 
2206
        get_rev_id_for_revno verb.  If the verb is unknown the VFS fallback
 
2207
        will be invoked, which will fail if the repo is unlocked.
 
2208
        """
 
2209
        self.setup_smart_server_with_call_log()
 
2210
        tree = self.make_branch_and_memory_tree('.')
 
2211
        tree.lock_write()
 
2212
        rev1 = tree.commit('First')
 
2213
        rev2 = tree.commit('Second')
 
2214
        tree.unlock()
 
2215
        branch = tree.branch
 
2216
        self.assertFalse(branch.is_locked())
 
2217
        self.reset_smart_call_log()
 
2218
        verb = 'Repository.get_rev_id_for_revno'
 
2219
        self.disable_verb(verb)
 
2220
        self.assertEqual(rev1, branch.get_rev_id(1))
 
2221
        self.assertLength(1, [call for call in self.hpss_calls if
 
2222
                              call.call.method == verb])
 
2223
 
2153
2224
 
2154
2225
class TestRepositoryIsShared(TestRemoteRepository):
2155
2226