예제 #1
0
 def test_delete_directory(self, dir_function):
     basepath = dir_function.path
     directory = 'a'
     file_manager.create_package_directories(basepath, directory)
     path = os.path.join(basepath, directory)
     errors = file_manager.delete_directory(path)
     assert errors == []
     assert not os.path.isdir(path)
예제 #2
0
 def delete_directory(self, dir_name, file_type):
     errors = []
     base_path = self.element_directory_path(file_type)
     relpath = os.sep.join(dir_name.split('.'))
     fullpath = os.path.join(base_path, relpath)
     if not os.path.isdir(fullpath):
         errors.append('Directory {} does not exist'.format(relpath))
     else:
         errors = file_manager.delete_directory(fullpath)
     return errors
예제 #3
0
 def test_delete_directory_with_files_and_folders(self, dir_function, test_utils):
     basepath = dir_function.path
     directory = 'a'
     file_manager.create_package_directories(basepath, directory)
     file_manager.create_package_directories(os.path.join(basepath, directory), 'foo')
     test_utils.create_empty_file(os.path.join(basepath, directory), 'bar.txt')
     path = os.path.join(basepath, directory)
     errors = file_manager.delete_directory(path)
     assert errors == []
     assert not os.path.isdir(path)
예제 #4
0
 def test_delete_directory_a_child_file_is_open(self, dir_function, test_utils):
     basepath = dir_function.path
     directory = 'a'
     file_manager.create_package_directories(basepath, directory)
     filename_one = test_utils.create_empty_file(os.path.join(basepath, directory), 'foo.txt')
     filename_two = test_utils.create_empty_file(os.path.join(basepath, directory), 'bar.txt')
     path = os.path.join(basepath, directory)
     with open(filename_one):
         errors = file_manager.delete_directory(path)
         assert errors == ['Error: PermissionError']
     assert os.path.isdir(path)
     # open file was not removed
     assert os.path.isfile(filename_one)
     # not open file was removed
     assert not os.path.isfile(filename_two)
예제 #5
0
def delete_project(project_name):
    """Delete an entire project.
    DANGER
    """
    return file_manager.delete_directory(Project(project_name).path)
예제 #6
0
 def test_delete_directory_does_not_exist(self, dir_function):
     basepath = dir_function.path
     directory = 'a'
     path = os.path.join(basepath, directory)
     errors = file_manager.delete_directory(path)
     assert errors == ['Directory does not exist']