~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-06 04:30:17 UTC
  • mto: This revision was merged to the branch mainline in revision 1593.
  • Revision ID: mbp@sourcefrog.net-20060306043017-2e9a7d43ee9c5745
Locks protecting LockableFiles must now be explicitly created before use.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
        super(TestLockableFiles_TransportLock, self).setUp()
99
99
        transport = get_transport('.')
100
100
        transport.mkdir('.bzr')
101
 
        transport.put('.bzr/my-lock', StringIO(''))
102
101
        sub_transport = transport.clone('.bzr')
103
102
        self.lockable = LockableFiles(sub_transport, 'my-lock')
 
103
        self.lockable.create_lock()
104
104
 
105
105
        
106
106
 
110
110
 
111
111
    def setUp(self):
112
112
        super(TestLockableFiles_LockDir, self).setUp()
113
 
        transport = get_transport('.')
114
 
        self.lockable = LockableFiles(transport, 'my-lock', LockDir)
 
113
        self.transport = get_transport('.')
 
114
        self.lockable = LockableFiles(self.transport, 'my-lock', LockDir)
 
115
        self.lockable.create_lock()
115
116
 
116
117
    def test_lock_is_lockdir(self):
117
118
        """Created instance should use a LockDir.
123
124
                              ## LockDirStrategy)
124
125
 
125
126
    def test_lock_created(self):
126
 
        transport = get_transport('.')
127
 
        lockable = LockableFiles(transport, 'my-lock', LockDir)
128
 
        lockable.create_lock()
129
 
        self.assertTrue(transport.has('my-lock'))
130
 
        lockable.lock_write()
131
 
        self.assertTrue(transport.has('my-lock/held/info'))
132
 
        lockable.unlock()
133
 
 
 
127
        self.assertTrue(self.transport.has('my-lock'))
 
128
        self.lockable.lock_write()
 
129
        self.assertTrue(self.transport.has('my-lock/held/info'))
 
130
        self.lockable.unlock()
 
131
        self.assertFalse(self.transport.has('my-lock/held/info'))
 
132
        self.assertTrue(self.transport.has('my-lock'))
 
133
 
 
134
 
 
135
    # TODO: Test the lockdir inherits the right file and directory permissions
 
136
    # from the LockableFiles.