~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_locking.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-11 11:47:36 UTC
  • mfrom: (5200.3.8 lock_return)
  • Revision ID: pqm@pqm.ubuntu.com-20100511114736-mc1sq9zyo3vufec7
(lifeless) Provide a consistent interface to Tree, Branch,
 Repository where lock methods return an object with an unlock method to
 unlock the lock. This breaks the API for Branch,
 Repository on their lock_write methods. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    lockdir,
25
25
    )
26
26
from bzrlib.tests import TestSkipped
 
27
from bzrlib.tests.matchers import *
27
28
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
28
29
 
29
30
 
44
45
        self.assertFalse(wt.is_locked())
45
46
        self.assertFalse(wt.branch.is_locked())
46
47
 
 
48
    def test_lock_read_returns_unlocker(self):
 
49
        wt = self.make_branch_and_tree('.')
 
50
        self.assertThat(wt.lock_read, ReturnsUnlockable(wt))
 
51
 
47
52
    def test_trivial_lock_write_unlock(self):
48
53
        """Locking for write and unlocking should work trivially."""
49
54
        wt = self.make_branch_and_tree('.')
59
64
        self.assertFalse(wt.is_locked())
60
65
        self.assertFalse(wt.branch.is_locked())
61
66
 
 
67
    def test_lock_write_returns_unlocker(self):
 
68
        wt = self.make_branch_and_tree('.')
 
69
        self.assertThat(wt.lock_write, ReturnsUnlockable(wt))
 
70
 
62
71
    def test_trivial_lock_tree_write_unlock(self):
63
72
        """Locking for tree write is ok when the branch is not locked."""
64
73
        wt = self.make_branch_and_tree('.')
74
83
        self.assertFalse(wt.is_locked())
75
84
        self.assertFalse(wt.branch.is_locked())
76
85
 
 
86
    def test_lock_tree_write_returns_unlocker(self):
 
87
        wt = self.make_branch_and_tree('.')
 
88
        self.assertThat(wt.lock_tree_write, ReturnsUnlockable(wt))
 
89
 
77
90
    def test_trivial_lock_tree_write_branch_read_locked(self):
78
91
        """It is ok to lock_tree_write when the branch is read locked."""
79
92
        wt = self.make_branch_and_tree('.')