mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #24105 -- Called Storage.get_valid_name() when upload_to is callable
This commit is contained in:
parent
7c7b855106
commit
9de9c24017
5 changed files with 39 additions and 6 deletions
|
@ -597,6 +597,16 @@ class FileFieldStorageTests(SimpleTestCase):
|
|||
self.assertTrue(obj.random.name.endswith("/random_file"))
|
||||
obj.random.close()
|
||||
|
||||
def test_custom_valid_name_callable_upload_to(self):
|
||||
"""
|
||||
Storage.get_valid_name() should be called when upload_to is a callable.
|
||||
"""
|
||||
obj = Storage()
|
||||
obj.custom_valid_name.save("random_file", ContentFile("random content"))
|
||||
# CustomValidNameStorage.get_valid_name() appends '_valid' to the name
|
||||
self.assertTrue(obj.custom_valid_name.name.endswith("/random_file_valid"))
|
||||
obj.custom_valid_name.close()
|
||||
|
||||
def test_filefield_pickling(self):
|
||||
# Push an object into the cache to make sure it pickles properly
|
||||
obj = Storage()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue