Commits

David Bennett committed 4323040

Adding some tests.

Comments (0)

Files changed (3)

private_media/fields.py

+from django.db.models.fields.files import FileField
+
+
+class PrivateFileField(FileField):
+    pass

private_media/tests/models.py

+from django.db import models
+from private_media.fields import PrivateFileField
+
+
+class Storage(models.Model):
+    normal = PrivateFileField()

private_media/tests/tests.py

+import shutil
+from django.conf import settings
+from django.core.files.storage import default_storage
+from django.core.files.uploadedfile import SimpleUploadedFile
+from django.test import TestCase
+from models import Storage
+
+
+class FileTests(TestCase):
+    def setUp(self):
+        obj = Storage()
+        obj.normal = SimpleUploadedFile("django_test.txt", "content")
+        obj.save()
+
+    def tearDown(self):
+        shutil.rmtree(settings.MEDIA_ROOT)
+
+    def test_file_exists(self):
+        dirs, files = default_storage.listdir()
+        self.assertEqual(
+            sorted(files), ["django_test.txt"]
+        )