~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-26 21:33:20 UTC
  • mfrom: (3015.2.15 pack.read-locks)
  • Revision ID: pqm@pqm.ubuntu.com-20071126213320-adxxra3gsie5inhw
(robertc) Many fixes to support packs on the smart server and as the
        default format. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for the smart wire/domain protocol.
18
18
 
19
19
This module contains tests for the domain-level smart requests and responses,
20
 
such as the 'Branch.lock_write' request.
 
20
such as the 'Branch.lock_write' request. Many of these use specific disk
 
21
formats to exercise calls that only make sense for formats with specific
 
22
properties.
21
23
 
22
24
Tests for low-level protocol encoding are found in test_smart_transport.
23
25
"""
378
380
    def test_lock_write_on_unlocked_branch(self):
379
381
        backing = self.get_transport()
380
382
        request = smart.branch.SmartServerBranchRequestLockWrite(backing)
381
 
        branch = self.make_branch('.')
 
383
        branch = self.make_branch('.', format='knit')
382
384
        repository = branch.repository
383
385
        response = request.execute(backing.local_abspath(''))
384
386
        branch_nonce = branch.control_files._lock.peek().get('nonce')
405
407
    def test_lock_write_with_tokens_on_locked_branch(self):
406
408
        backing = self.get_transport()
407
409
        request = smart.branch.SmartServerBranchRequestLockWrite(backing)
408
 
        branch = self.make_branch('.')
 
410
        branch = self.make_branch('.', format='knit')
409
411
        branch_token = branch.lock_write()
410
412
        repo_token = branch.repository.lock_write()
411
413
        branch.repository.unlock()
420
422
    def test_lock_write_with_mismatched_tokens_on_locked_branch(self):
421
423
        backing = self.get_transport()
422
424
        request = smart.branch.SmartServerBranchRequestLockWrite(backing)
423
 
        branch = self.make_branch('.')
 
425
        branch = self.make_branch('.', format='knit')
424
426
        branch_token = branch.lock_write()
425
427
        repo_token = branch.repository.lock_write()
426
428
        branch.repository.unlock()
435
437
    def test_lock_write_on_locked_repo(self):
436
438
        backing = self.get_transport()
437
439
        request = smart.branch.SmartServerBranchRequestLockWrite(backing)
438
 
        branch = self.make_branch('.')
 
440
        branch = self.make_branch('.', format='knit')
439
441
        branch.repository.lock_write()
440
442
        branch.repository.leave_lock_in_place()
441
443
        branch.repository.unlock()
462
464
    def test_unlock_on_locked_branch_and_repo(self):
463
465
        backing = self.get_transport()
464
466
        request = smart.branch.SmartServerBranchRequestUnlock(backing)
465
 
        branch = self.make_branch('.')
 
467
        branch = self.make_branch('.', format='knit')
466
468
        # Lock the branch
467
469
        branch_token = branch.lock_write()
468
470
        repo_token = branch.repository.lock_write()
485
487
    def test_unlock_on_unlocked_branch_unlocked_repo(self):
486
488
        backing = self.get_transport()
487
489
        request = smart.branch.SmartServerBranchRequestUnlock(backing)
488
 
        branch = self.make_branch('.')
 
490
        branch = self.make_branch('.', format='knit')
489
491
        response = request.execute(
490
492
            backing.local_abspath(''), 'branch token', 'repo token')
491
493
        self.assertEqual(
494
496
    def test_unlock_on_unlocked_branch_locked_repo(self):
495
497
        backing = self.get_transport()
496
498
        request = smart.branch.SmartServerBranchRequestUnlock(backing)
497
 
        branch = self.make_branch('.')
 
499
        branch = self.make_branch('.', format='knit')
498
500
        # Lock the repository.
499
501
        repo_token = branch.repository.lock_write()
500
502
        branch.repository.leave_lock_in_place()
690
692
    def test_lock_write_on_unlocked_repo(self):
691
693
        backing = self.get_transport()
692
694
        request = smart.repository.SmartServerRepositoryLockWrite(backing)
693
 
        repository = self.make_repository('.')
 
695
        repository = self.make_repository('.', format='knit')
694
696
        response = request.execute(backing.local_abspath(''))
695
697
        nonce = repository.control_files._lock.peek().get('nonce')
696
698
        self.assertEqual(SmartServerResponse(('ok', nonce)), response)
702
704
    def test_lock_write_on_locked_repo(self):
703
705
        backing = self.get_transport()
704
706
        request = smart.repository.SmartServerRepositoryLockWrite(backing)
705
 
        repository = self.make_repository('.')
 
707
        repository = self.make_repository('.', format='knit')
706
708
        repository.lock_write()
707
709
        repository.leave_lock_in_place()
708
710
        repository.unlock()
713
715
    def test_lock_write_on_readonly_transport(self):
714
716
        backing = self.get_readonly_transport()
715
717
        request = smart.repository.SmartServerRepositoryLockWrite(backing)
716
 
        repository = self.make_repository('.')
 
718
        repository = self.make_repository('.', format='knit')
717
719
        response = request.execute('')
718
720
        self.assertFalse(response.is_successful())
719
721
        self.assertEqual('LockFailed', response.args[0])
728
730
    def test_unlock_on_locked_repo(self):
729
731
        backing = self.get_transport()
730
732
        request = smart.repository.SmartServerRepositoryUnlock(backing)
731
 
        repository = self.make_repository('.')
 
733
        repository = self.make_repository('.', format='knit')
732
734
        token = repository.lock_write()
733
735
        repository.leave_lock_in_place()
734
736
        repository.unlock()
744
746
    def test_unlock_on_unlocked_repo(self):
745
747
        backing = self.get_transport()
746
748
        request = smart.repository.SmartServerRepositoryUnlock(backing)
747
 
        repository = self.make_repository('.')
 
749
        repository = self.make_repository('.', format='knit')
748
750
        response = request.execute(backing.local_abspath(''), 'some token')
749
751
        self.assertEqual(
750
752
            SmartServerResponse(('TokenMismatch',)), response)