~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockable_files.py

  • Committer: John Arbash Meinel
  • Date: 2007-12-13 20:17:06 UTC
  • mto: This revision was merged to the branch mainline in revision 3121.
  • Revision ID: john@arbash-meinel.com-20071213201706-nt8f4om80gyn6l6v
Fix LockableFiles to not use modes that allow the user to write to things they create.
It seems that cygwin + FAT32 will report all directories as readonly,
even though they are not.
Regardless, someone might have .bzr/repository as readonly, but still
allow you to create files in a subdirectory.
Either way, there is no reason to have a file that we are going to
write to be created readonly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from StringIO import StringIO
18
18
 
19
19
import bzrlib
20
 
import bzrlib.errors as errors
 
20
from bzrlib import (
 
21
    errors,
 
22
    lockdir,
 
23
    osutils,
 
24
    )
21
25
from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError
22
26
from bzrlib.lockable_files import LockableFiles, TransportLock
23
 
from bzrlib import lockdir
24
 
from bzrlib.lockdir import LockDir
25
27
from bzrlib.tests import TestCaseInTempDir
26
28
from bzrlib.tests.test_smart import TestCaseWithSmartMedium
27
29
from bzrlib.tests.test_transactions import DummyWeave
347
349
        self.lockable.create_lock()
348
350
 
349
351
    def get_lockable(self):
350
 
        return LockableFiles(self.transport, 'my-lock', LockDir)
 
352
        return LockableFiles(self.transport, 'my-lock', lockdir.LockDir)
351
353
 
352
354
    def test_lock_created(self):
353
355
        self.assertTrue(self.transport.has('my-lock'))
357
359
        self.assertFalse(self.transport.has('my-lock/held/info'))
358
360
        self.assertTrue(self.transport.has('my-lock'))
359
361
 
 
362
    def test__file_modes(self):
 
363
        self.transport.mkdir('readonly')
 
364
        osutils.make_readonly('readonly')
 
365
        lockable = LockableFiles(self.transport.clone('readonly'), 'test-lock',
 
366
                                 lockdir.LockDir)
 
367
        # The directory mode should be read-write-execute for the current user
 
368
        self.assertEqual(00700, lockable._dir_mode & 00700)
 
369
        # Files should be read-write for the current user
 
370
        self.assertEqual(00600, lockable._file_mode & 00700)
360
371
 
361
 
    # TODO: Test the lockdir inherits the right file and directory permissions
362
 
    # from the LockableFiles.
363
 
        
364
372
 
365
373
class TestLockableFiles_RemoteLockDir(TestCaseWithSmartMedium,
366
374
                              _TestLockableFiles_mixin):