Esempio n. 1
0
 def test_missing_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_DIR missing. It should exit returning False."""
     # None case.
     settings.AUTO_UPLOAD_DIR = None
     self.assertFalse(Command.create_auto_upload_dirs())
     # Empty case.
     settings.AUTO_UPLOAD_DIR = ""
     self.assertFalse(Command.create_auto_upload_dirs())
Esempio n. 2
0
 def test_missing_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_DIR missing. It should exit returning False."""
     # None case.
     settings.AUTO_UPLOAD_DIR = None
     self.assertFalse(Command.create_auto_upload_dirs())
     # Empty case.
     settings.AUTO_UPLOAD_DIR = ""
     self.assertFalse(Command.create_auto_upload_dirs())
Esempio n. 3
0
 def test_auto_upload_sync_creation(self):
     """Tests automated case folder creation."""
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Set path and test.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     # Create base dir.
     Command.create_auto_upload_dirs()
     # Create case.
     case = Case.objects.create(name="a", owner=self.user)
     dir_name = os.path.join(settings.AUTO_UPLOAD_DIR, case.directory_name)
     self.assertTrue(os.path.exists(dir_name))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 4
0
 def test_case_folders_creation(self):
     # Create cases.
     case1 = Case.objects.create(name="aaa", owner=self.user)
     case2 = Case.objects.create(name="aab", owner=self.user)
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Set path and create folders.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     Command.create_auto_upload_dirs()
     # Test.
     for case in [case1, case2]:
         case_path = os.path.join(ghiro_path, case.directory_name)
         self.assertTrue(os.path.exists(case_path))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 5
0
 def test_case_folders_creation(self):
     # Create cases.
     case1 = Case.objects.create(name="aaa", owner=self.user)
     case2 = Case.objects.create(name="aab", owner=self.user)
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Set path and create folders.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     Command.create_auto_upload_dirs()
     # Test.
     for case in [case1, case2]:
         case_path = os.path.join(ghiro_path, case.directory_name)
         self.assertTrue(os.path.exists(case_path))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 6
0
 def test_create_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_DIR creation when missing."""
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Set path and test.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     self.assertNotEqual(Command.create_auto_upload_dirs(), False)
     self.assertTrue(os.path.exists(ghiro_path))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 7
0
 def test_create_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_DIR creation when missing."""
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Set path and test.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     self.assertNotEqual(Command.create_auto_upload_dirs(), False)
     self.assertTrue(os.path.exists(ghiro_path))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 8
0
 def test_cleanup_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_STARTUP_CLEANUP."""
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Set path and create folders.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     os.mkdir(ghiro_path)
     # Test folder.
     test_path = os.path.join(ghiro_path, "test")
     os.mkdir(test_path)
     # Test 1: not cleaning.
     settings.AUTO_UPLOAD_STARTUP_CLEANUP = False
     Command.create_auto_upload_dirs()
     self.assertTrue(os.path.exists(test_path))
     # Test 2: cleaning.
     settings.AUTO_UPLOAD_STARTUP_CLEANUP = True
     Command.create_auto_upload_dirs()
     self.assertFalse(os.path.exists(test_path))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 9
0
 def test_cleanup_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_STARTUP_CLEANUP."""
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Set path and create folders.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     os.mkdir(ghiro_path)
     # Test folder.
     test_path = os.path.join(ghiro_path, "test")
     os.mkdir(test_path)
     # Test 1: not cleaning.
     settings.AUTO_UPLOAD_STARTUP_CLEANUP = False
     Command.create_auto_upload_dirs()
     self.assertTrue(os.path.exists(test_path))
     # Test 2: cleaning.
     settings.AUTO_UPLOAD_STARTUP_CLEANUP = True
     Command.create_auto_upload_dirs()
     self.assertFalse(os.path.exists(test_path))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 10
0
 def test_existent_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_DIR creation when it already exist."""
     # Create cases.
     case1 = Case.objects.create(name="aaa", owner=self.user)
     case2 = Case.objects.create(name="aab", owner=self.user)
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Create AUTO_UPLOAD_DIR.
     os.mkdir(ghiro_path)
     # Set path and test.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     self.assertNotEqual(Command.create_auto_upload_dirs(), False)
     self.assertTrue(os.path.exists(ghiro_path))
     # Cleanup.
     shutil.rmtree(tmp_path)
Esempio n. 11
0
 def test_existent_auto_upload_dir(self):
     """Test for AUTO_UPLOAD_DIR creation when it already exist."""
     # Create cases.
     case1 = Case.objects.create(name="aaa", owner=self.user)
     case2 = Case.objects.create(name="aab", owner=self.user)
     # Create temporary directory to store everything.
     tmp_path = tempfile.mkdtemp()
     # Build the ghiro path for auto upload.
     ghiro_path = os.path.join(tmp_path, "ghiro-test")
     # Create AUTO_UPLOAD_DIR.
     os.mkdir(ghiro_path)
     # Set path and test.
     settings.AUTO_UPLOAD_DIR = ghiro_path
     self.assertNotEqual(Command.create_auto_upload_dirs(), False)
     self.assertTrue(os.path.exists(ghiro_path))
     # Cleanup.
     shutil.rmtree(tmp_path)