24
24
from cStringIO import StringIO
26
from bzrlib import bzrdir, remote, tests
27
32
from bzrlib.branch import Branch
28
33
from bzrlib.bzrdir import BzrDir, BzrDirFormat
29
from bzrlib.errors import NoSuchRevision
30
34
from bzrlib.remote import (
202
206
branch = RemoteBranch(bzrdir, None, _client=client)
204
208
self.assertRaises(
205
NoSuchRevision, branch.set_revision_history, ['rev-id'])
209
errors.NoSuchRevision, branch.set_revision_history, ['rev-id'])
208
212
class TestBranchControlGetBranchConf(tests.TestCase):
359
363
repo, client = self.setup_fake_client_and_repository(
360
364
responses, transport_path)
361
365
# also check that the right revision is reported in the error
362
self.assertRaises(NoSuchRevision,
366
self.assertRaises(errors.NoSuchRevision,
363
367
repo.get_revision_graph, revid)
364
368
self.assertEqual(
365
369
[('call2', 'Repository.get_revision_graph', ('///sinhala/', revid))],
391
395
[('call', 'Repository.is_shared', ('///qwack/',))],
393
397
self.assertEqual(False, result)
400
class TestRepositoryLockWrite(TestRemoteRepository):
402
def test_lock_write(self):
403
responses = [(('ok', 'a token'), '')]
404
transport_path = 'quack'
405
repo, client = self.setup_fake_client_and_repository(
406
responses, transport_path)
407
result = repo.lock_write()
409
[('call', 'Repository.lock_write', ('///quack/',))],
411
self.assertEqual('a token', result)
413
def test_lock_write_already_locked(self):
414
responses = [(('LockContention', ), '')]
415
transport_path = 'quack'
416
repo, client = self.setup_fake_client_and_repository(
417
responses, transport_path)
418
self.assertRaises(errors.LockContention, repo.lock_write)
420
[('call', 'Repository.lock_write', ('///quack/',))],
424
class TestRepositoryUnlock(TestRemoteRepository):
426
def test_unlock(self):
427
responses = [(('ok', 'a token'), ''),
429
transport_path = 'quack'
430
repo, client = self.setup_fake_client_and_repository(
431
responses, transport_path)
435
[('call', 'Repository.lock_write', ('///quack/',)),
436
('call', 'Repository.unlock', ('///quack/', 'a token'))],
439
def test_unlock_wrong_token(self):
440
# If somehow the token is wrong, unlock will raise TokenMismatch.
441
responses = [(('ok', 'a token'), ''),
442
(('TokenMismatch',), '')]
443
transport_path = 'quack'
444
repo, client = self.setup_fake_client_and_repository(
445
responses, transport_path)
447
self.assertRaises(errors.TokenMismatch, repo.unlock)