From ff420b43647dd7f149f000efd2c7eb077f6ba5cf Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 27 Aug 2008 22:21:14 +0000 Subject: Fixed #8454: added a FILE_UPLOAD_PERMISSIONS setting to control the permissoin of files uploaded by the built-in file storage system. Thanks, dcwatson. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8640 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/file_storage/tests.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py index 3f059c7f3c..181c551c24 100644 --- a/tests/regressiontests/file_storage/tests.py +++ b/tests/regressiontests/file_storage/tests.py @@ -86,9 +86,10 @@ u'custom_storage.2' # Tests for a race condition on file saving (#4948). # This is written in such a way that it'll always pass on platforms # without threading. - +import os import time from unittest import TestCase +from django.conf import settings from django.core.files.base import ContentFile from models import temp_storage try: @@ -117,3 +118,15 @@ class FileSaveRaceConditionTest(TestCase): temp_storage.delete('conflict') temp_storage.delete('conflict_') +class FileStoragePermissions(TestCase): + def setUp(self): + self.old_perms = settings.FILE_UPLOAD_PERMISSIONS + settings.FILE_UPLOAD_PERMISSIONS = 0666 + + def test_file_upload_permissions(self): + name = temp_storage.save("the_file", ContentFile("data")) + actual_mode = os.stat(temp_storage.path(name))[0] & 0777 + self.assertEqual(actual_mode, 0666) + + def tearDown(self): + settings.FILE_UPLOAD_PERMISSIONS = self.old_perms \ No newline at end of file -- cgit v1.3