summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-10-11 08:07:25 -0400
committerTim Graham <timograham@gmail.com>2013-10-11 08:07:25 -0400
commit945e033a6964c8c83c1c5ce5f188baf41a7a7701 (patch)
tree4e4db1be3dab164327810f8505088bda6b9ce954 /tests
parentb67ab75e82ec59dd4eeca119eeaf570d7c88556c (diff)
Fixed #8918 -- Made FileField.upload_to optional.
Thanks leahculver for the suggestion and dc and vajrasky for work on the patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/files/models.py1
-rw-r--r--tests/files/tests.py6
-rw-r--r--tests/invalid_models/invalid_models/models.py2
3 files changed, 7 insertions, 2 deletions
diff --git a/tests/files/models.py b/tests/files/models.py
index 4134472748..eea3ddaf09 100644
--- a/tests/files/models.py
+++ b/tests/files/models.py
@@ -28,3 +28,4 @@ class Storage(models.Model):
custom = models.FileField(storage=temp_storage, upload_to=custom_upload_to)
random = models.FileField(storage=temp_storage, upload_to=random_upload_to)
default = models.FileField(storage=temp_storage, upload_to='tests', default='tests/default.txt')
+ empty = models.FileField(storage=temp_storage)
diff --git a/tests/files/tests.py b/tests/files/tests.py
index 36664fa83a..40aa9f6d75 100644
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -106,6 +106,12 @@ class FileStorageTests(TestCase):
obj4.random.save("random_file", ContentFile("random content"))
self.assertTrue(obj4.random.name.endswith("/random_file"))
+ # upload_to can be empty, meaning it does not use subdirectory.
+ obj5 = Storage()
+ obj5.empty.save('django_test.txt', ContentFile('more content'))
+ self.assertEqual(obj5.empty.name, "./django_test.txt")
+ self.assertEqual(obj5.empty.read(), b"more content")
+
def test_file_object(self):
# Create sample file
temp_storage.save('tests/example.txt', ContentFile('some content'))
diff --git a/tests/invalid_models/invalid_models/models.py b/tests/invalid_models/invalid_models/models.py
index 1113c0c056..8e04a4d328 100644
--- a/tests/invalid_models/invalid_models/models.py
+++ b/tests/invalid_models/invalid_models/models.py
@@ -19,7 +19,6 @@ class FieldErrors(models.Model):
decimalfield3 = models.DecimalField(max_digits="bad", decimal_places="bad")
decimalfield4 = models.DecimalField(max_digits=9, decimal_places=10)
decimalfield5 = models.DecimalField(max_digits=10, decimal_places=10)
- filefield = models.FileField()
choices = models.CharField(max_length=10, choices='bad')
choices2 = models.CharField(max_length=10, choices=[(1, 2, 3), (1, 2, 3)])
index = models.CharField(max_length=10, db_index='bad')
@@ -424,7 +423,6 @@ invalid_models.fielderrors: "decimalfield2": DecimalFields require a "max_digits
invalid_models.fielderrors: "decimalfield3": DecimalFields require a "decimal_places" attribute that is a non-negative integer.
invalid_models.fielderrors: "decimalfield3": DecimalFields require a "max_digits" attribute that is a positive integer.
invalid_models.fielderrors: "decimalfield4": DecimalFields require a "max_digits" attribute value that is greater than or equal to the value of the "decimal_places" attribute.
-invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute.
invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a tuple or list).
invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-item iterables (e.g. list of 2 item tuples).
invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-item iterables (e.g. list of 2 item tuples).