~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockable_files.py

  • Committer: Martin Pool
  • Date: 2006-03-03 06:07:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1593.
  • Revision ID: mbp@sourcefrog.net-20060303060711-51b8200efda1847b
Get LockableFiles tests running against LockDir

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from bzrlib.branch import Branch
20
20
from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError
21
 
from bzrlib.lockable_files import LockableFiles
 
21
from bzrlib.lockable_files import LockableFiles, LockDirStrategy
22
22
from bzrlib.tests import TestCaseInTempDir
23
23
from bzrlib.transactions import PassThroughTransaction, ReadOnlyTransaction
24
24
from bzrlib.transport import get_transport
25
25
 
26
26
 
27
 
 
28
27
# these tests are applied in each parameterized suite for LockableFiles
29
28
class _TestLockableFiles_mixin(object):
30
29
 
91
90
# This method of adapting tests to parameters is different to 
92
91
# the TestProviderAdapters used elsewhere, but seems simpler for this 
93
92
# case.  
94
 
def TestLockableFiles_OldLock(TestCaseInTempDir,
 
93
class TestLockableFiles_OldLock(TestCaseInTempDir,
95
94
                              _TestLockableFiles_mixin):
96
95
 
97
96
    def setUp(self):
99
98
        transport = get_transport('.')
100
99
        transport.mkdir('.bzr')
101
100
        transport.put('.bzr/my-lock', StringIO(''))
102
 
        self.lockable = LockableFiles(transport.clone('.bzr'), 'my-lock')
 
101
        sub_transport = transport.clone('.bzr')
 
102
        self.lockable = LockableFiles(sub_transport, 'my-lock')
 
103
        
 
104
 
 
105
class TestLockableFiles_LockDir(TestCaseInTempDir,
 
106
                              _TestLockableFiles_mixin):
 
107
    """LockableFile tests run with LockDir underneath"""
 
108
 
 
109
    def setUp(self):
 
110
        super(TestLockableFiles_LockDir, self).setUp()
 
111
        transport = get_transport('.')
 
112
        self.lockable = LockableFiles(transport, 'my-lock',
 
113
                                      LockDirStrategy)
 
114
 
 
115
    def test_lock_is_lockdir(self):
 
116
        """Created instance should use a LockDir.
 
117
        
 
118
        This primarily tests the mixin adapter works properly.
 
119
        """
 
120
        ## self.assertIsInstance(self.lockable, LockableFiles)
 
121
        ## self.assertIsInstance(self.lockable._lock_strategy,
 
122
                              ## LockDirStrategy)