from django.conf import settings
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from django.core.management.base import BaseCommand


class Command(BaseCommand):
    """
    Test various file storage operations, to ensure that integrations (with ie.
    Amazon S3) is working properly.
    """

    help = 'Test file storage operations.'

    def handle(self, *args, **options):

        verbosity = int(options.get('verbosity', 1))
        filename = 'storage_test'

        if verbosity > 0:
            self.stdout.write('Storage used: %s\n' % settings.DEFAULT_FILE_STORAGE)

        # Create a file
        default_storage.save(filename, ContentFile('We are testing, 1 2 three.'))

        # Check for existence
        file_exists = default_storage.exists(filename)

        if verbosity > 0:
            self.stdout.write('Does newly created file exist? %s\n' % file_exists)

        # Read back the file
        f = default_storage.open(filename, 'r')
        file_contents = f.read()
        f.close()

        if verbosity > 0:
            self.stdout.write('Contents: "%s"\n' % file_contents)

        # Delete the file
        default_storage.delete(filename)
        file_exists = default_storage.exists(filename)

        if verbosity > 0:
            self.stdout.write('Does file exist after deletion? %s\n' % file_exists)

@@ -11,179 +11,102 @@
 o.co
-nf import settings%0Afrom django.core.files.base import ContentFile%0Afrom django.core.files.storage import default_storage%0Afrom django.core.management.base import BaseCommand
+re.management.base import BaseCommand%0A%0Afrom doctor.services.storage import StorageServiceCheck
 %0A%0A%0Ac
@@ -403,24 +403,25 @@
 y', 1))%0A
+%0A
         
 filename
@@ -416,72 +416,35 @@
     
-filename = 'storage_test'%0A%0A        if verbosity %3E 0:%0A   
+# Check the status%0A
         
  sel
@@ -443,514 +443,200 @@
     
- 
 se
-lf.stdout.write('Storage used: %25s%5Cn' %25 settings.DEFAULT_FILE_STORAGE)%0A%0A        # Create a file%0A        default_storage.save(filename, ContentFile('We are testing, 1 2 three.'))%0A%0A        # Check for existence%0A        file_exists = default_storage.exists(filename)%0A%0A        if verbosity %3E 0:%0A            self.stdout.write('Does newly created file exist? %25s%5Cn' %25 file_exists)%0A%0A        # Read back the file%0A        f = default_storage.open(filename, 'r')%0A        file_contents = f.read()%0A        f.close()%0A%0A
+rvice_check = StorageServiceCheck()%0A        statuses = service_check.status()%0A%0A        # Iterate over the backends, print status%0A        for storage_name, info in statuses.iteritems():%0A%0A    
     
@@ -661,32 +661,36 @@
  0:%0A            
+    
 self.stdout.writ
@@ -696,193 +696,34 @@
 te('
-Contents: %22
 %25s
-%22
 %5Cn' %25 
-file_contents)%0A%0A        # Delete the file%0A        default_storage.delete(filename)%0A        file_exists = default_storage.exists(file
+storage_
 name)%0A
-%0A
     
-    if verbosity %3E 0:%0A
     
@@ -753,57 +753,31 @@
 te('
-Does file exist after deletion? %25s%5Cn' %25 file_exists
+%25s%5Cn%5Cn' %25 info%5B'message'%5D
 )%0A

Use service check class in test_storage management command.