Example #1
0
 def test_lock_permission(self):
     if not osutils.supports_posix_readonly():
         raise tests.TestSkipped('Cannot induce a permission failure')
     ld1 = self.get_lock()
     lock_path = ld1.transport.local_abspath('test_lock')
     os.mkdir(lock_path)
     osutils.make_readonly(lock_path)
     self.assertRaises(errors.LockFailed, ld1.attempt_lock)
Example #2
0
 def test_lock_permission(self):
     if not osutils.supports_posix_readonly():
         raise tests.TestSkipped('Cannot induce a permission failure')
     ld1 = self.get_lock()
     lock_path = ld1.transport.local_abspath('test_lock')
     os.mkdir(lock_path)
     osutils.make_readonly(lock_path)
     self.assertRaises(errors.LockFailed, ld1.attempt_lock)
Example #3
0
 def test__file_modes(self):
     self.transport.mkdir('readonly')
     osutils.make_readonly('readonly')
     lockable = LockableFiles(self.transport.clone('readonly'), 'test-lock',
                              lockdir.LockDir)
     # The directory mode should be read-write-execute for the current user
     self.assertEqual(00700, lockable._dir_mode & 00700)
     # Files should be read-write for the current user
     self.assertEqual(00600, lockable._file_mode & 00700)
 def test__file_modes(self):
     self.transport.mkdir('readonly')
     osutils.make_readonly('readonly')
     lockable = LockableFiles(self.transport.clone('readonly'), 'test-lock',
                              lockdir.LockDir)
     # The directory mode should be read-write-execute for the current user
     self.assertEqual(00700, lockable._dir_mode & 00700)
     # Files should be read-write for the current user
     self.assertEqual(00600, lockable._file_mode & 00700)
Example #5
0
    def _make_readonly(self):
        """
    Make the contents of the temporary directory read-only.
    """
        if self.readonly:
            for (directory, subdirs, files) in os.walk(self.path):
                for file in files:
                    osutils.make_readonly(osutils.pathjoin(directory, file))

        return
Example #6
0
    def _make_readonly(self):
        """
    Make the contents of the temporary directory read-only.
    """
        if self.readonly:
            for (directory, subdirs, files) in os.walk(self.path):
                for file in files:
                    osutils.make_readonly(osutils.pathjoin(directory, file))

        return
Example #7
0
    def test_readonly_file(self):
        """If the file is readonly, we can take a read lock.

        But we shouldn't be able to take a write lock.
        """
        osutils.make_readonly('a-file')
        # Make sure the file is read-only (on all platforms)
        self.assertRaises(IOError, open, 'a-file', 'rb+')
        a_lock = self.read_lock('a-file')
        a_lock.unlock()

        self.assertRaises(errors.LockFailed, self.write_lock, 'a-file')
Example #8
0
    def test_readonly_file(self):
        """If the file is readonly, we can take a read lock.

        But we shouldn't be able to take a write lock.
        """
        osutils.make_readonly('a-file')
        # Make sure the file is read-only (on all platforms)
        self.assertRaises(IOError, open, 'a-file', 'rb+')
        a_lock = self.read_lock('a-file')
        a_lock.unlock()

        self.assertRaises(errors.LockFailed, self.write_lock, 'a-file')