def test_create_tmp_folder_remove_previous_folder(self): os.makedirs( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name', 'folder-to-be-removed')) paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', 'test-repo') ProjectFolderManager.create_tmp_folder_for_git_project(paths) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name'))) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name'))) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name', 'project'))) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name', 'log'))) self.assertFalse( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name', 'folder-to-be-removed')))
def create_project_folders(self): paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', 'test-repo') ProjectFolderManager.create_tmp_folder_for_git_project(paths) return paths
def test_is_not_log_project_folder_present(self): paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', 'test-repo') self.assertFalse( ProjectFolderManager.is_log_project_folder_present(paths))
def test_if_local_search_path_is_dot_and_no_project_folder_then_path_equal_project( self): paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', '.') self.assertEqual(os.path.join(self.tmp_folder, 'tmp/folder/list'), paths['temp']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name'), paths['archive']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name'), paths['project_name']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project'), paths['project']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name/log'), paths['log']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project'), paths['git_project_search_path'])
def test_generated_folder_paths_are_correct(self): paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', 'test-repo') self.assertEqual(os.path.join(self.tmp_folder, 'tmp/folder/list'), paths['temp']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name'), paths['archive']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name'), paths['project_name']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project'), paths['project']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name/log'), paths['log']) self.assertEqual( os.path.join( self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project/test-repo'), paths['git_project_search_path'])
def create_project_folders_with_git_hidden_folder(self): paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', 'test-repo-2') ProjectFolderManager.create_tmp_folder_for_git_project(paths) os.makedirs(os.path.join(paths['project'], 'test-repo-1/.git')) os.makedirs(os.path.join(paths['project'], 'test-repo-2/.git')) os.makedirs(os.path.join(paths['project'], 'test-repo-3/.git')) return paths
def test_if_local_search_path_is_dot_folder_then_path_equal_first_git_project( self): os.makedirs( os.path.join( self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project/test-repo-1/.git' )) os.makedirs( os.path.join( self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project/test-repo-2/.git' )) os.makedirs( os.path.join( self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project/test-repo-3/.git' )) paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', '.') self.assertEqual(os.path.join(self.tmp_folder, 'tmp/folder/list'), paths['temp']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name'), paths['archive']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name'), paths['project_name']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project'), paths['project']) self.assertEqual( os.path.join(self.tmp_folder, 'tmp/folder/list/archive-name/project-name/log'), paths['log']) self.assertEqual( os.path.join( self.tmp_folder, 'tmp/folder/list/archive-name/project-name/project/test-repo-1' ), paths['git_project_search_path'])
def test_create_tmp_folder_for_git_project(self): paths = ProjectFolderManager.get_folder_paths( self.tmp_folder, ['tmp', 'folder', 'list'], 'archive-name', 'project-name', 'test-repo') ProjectFolderManager.create_tmp_folder_for_git_project(paths) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name'))) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name'))) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name', 'project'))) self.assertTrue( os.path.exists( os.path.join(self.tmp_folder, 'tmp/folder/list', 'archive-name', 'project-name', 'log')))