Anonymous committed 12c594d Draft

create s3boto tests

Comments (0)

Files changed (2)


 from storages.tests.hashpath import *
+from s3boto import *


+from django.test import TestCase
+from django.core.files.base import ContentFile
+from django.conf import settings
+from import FileSystemStorage
+from uuid import uuid4
+import os
+from storages.backends.s3boto import S3BotoStorage
+class S3BotoStorageTests(TestCase):
+    def setUp(self):
+ = S3BotoStorage()
+        # use a unique folder namespace for tests
+        path_prefix = "test-subfolder/"
+        dirs, files =
+        while dirs or files:
+            path_prefix = "test-subfolder-%s/" % uuid4()
+            dirs, files =
+        self.path_prefix = path_prefix
+    def prefix_path(self, path):
+        return "%s%s" % (self.path_prefix, path)
+    def test_storage_save(self):
+        name = self.prefix_path('test_storage_save.txt')
+        content = 'new content'
+, ContentFile(content))
+        self.assertEqual(, content)
+    def test_storage_open_for_writing(self):
+        name = self.prefix_path('test_open_for_writing.txt')
+        content = 'new content'
+        file =, 'w')
+        file.write(content)
+        file.close()
+        self.assertEqual(, content)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.