import string
import random
from django.test import TestCase
import os
from osmaxx.utils import PrivateSystemStorage


class PrivateSystemStorageTestCase(TestCase):
    def setUp(self):
        random_directory_name_length = 10
        self.random_directory_name = ''.join(
            random.choice(string.ascii_lowercase + string.digits) for _ in range(random_directory_name_length)
        )

    def test_creates_a_new_directory_if_it_does_not_exist(self):
        random_directory_path = os.path.join('/tmp/', self.random_directory_name)
        self.assertFalse(os.path.exists(random_directory_path))
        PrivateSystemStorage(location=random_directory_path)
        self.assertTrue(os.path.exists(random_directory_path))
        os.rmdir(random_directory_path)

    def xtest_raises_when_missing_permissions(self):
        # FIXME: this isn't testable as it stands, because we are root on the docker instance
        #        and it will overwrite the access rights to create a directory.
        read_only_directory = os.path.join('/tmp/', 'read_only_dir')
        os.mkdir(read_only_directory, mode=0o000)
        random_directory_path = os.path.join(read_only_directory, self.random_directory_name)
        self.assertFalse(os.path.exists(random_directory_path))
        with self.assertRaises(OSError):
            PrivateSystemStorage(location=random_directory_path)
        self.assertFalse(os.path.exists(random_directory_path))

@@ -1,32 +1,4 @@
-import string%0Aimport random%0A
 from
@@ -163,208 +163,69 @@
     
-random_directory_name_length = 10%0A        self.random_directory_name = ''.join(%0A            random.choice(string.ascii_lowercase + string.digits) for _ in range(random_directory_name_length)%0A        )
+self.directory_name = 'OSMAXX_OjM3cRB2xgSuDXr5yBxxzds9mO8gmP'
 %0A%0A  
@@ -287,39 +287,32 @@
 (self):%0A        
-random_
 directory_path =
@@ -335,31 +335,24 @@
 tmp/', self.
-random_
 directory_na
@@ -387,39 +387,32 @@
 (os.path.exists(
-random_
 directory_path))
@@ -442,39 +442,32 @@
 torage(location=
-random_
 directory_path)%0A
@@ -497,39 +497,32 @@
 (os.path.exists(
-random_
 directory_path))
@@ -539,23 +539,16 @@
 s.rmdir(
-random_
 director
@@ -910,23 +910,16 @@
         
-random_
 director
@@ -966,23 +966,16 @@
 y, self.
-random_
 director
@@ -1014,39 +1014,32 @@
 (os.path.exists(
-random_
 directory_path))
@@ -1122,23 +1122,16 @@
 ocation=
-random_
 director
@@ -1182,15 +1182,8 @@
 sts(
-random_
 dire

remove unnneccessary convoluted test directory creation