Example #1
0
def test_copy_files_everything():
    """

    This function tests the OSUtilities.copy_files function to ensure that it
    correctly copies all contents of a directory to a new directory
    """
    plat = platform.system()
    if plat == 'Darwin':
        source = '../data/test/move_directory3'
        destination = '../data/test/move_directory2'
        file1 = '../data/test/move_directory2/test1.txt'
        file2 = '../data/test/move_directory2/test2.txt'
        direct = '../data/test/move_directory2/test'
        ds = '../data/test/move_directory2/.DS_Store'
    else:
        source = r'..\data\test\move_directory3'
        destination = r'..\data\test\move_directory2'
        file1 = r'..\data\test\move_directory2\test1.txt'
        file2 = r'..\data\test\move_directory2\test2.txt'
        direct = r'..\data\test\move_directory2/test'
        ds = r' '

    util = OSUtilities()
    util.copy_files(destination, source)
    assert os.path.isfile(file1)
    assert os.path.isfile(file2)
    assert os.path.isdir(direct)
    shutil.rmtree(direct)
    os.remove(file1)
    os.remove(file2)
    if plat == 'Darwin':
        os.remove(ds)
Example #2
0
def test_copy_files_dirs():
    """

    This function tests the OSUtilities.copy_files function to ensure that it
    correctly copies all directories of a directory to a new directory
    """
    plat = platform.system()
    if plat == 'Darwin':
        source = '../data/test/move_directory3'
        destination = '../data/test/move_directory2'
        direct = '../data/test/move_directory2/test'
    else:
        source = r'..\data\test\move_directory3'
        destination = r'..\data\test\move_directory2'
        direct = r'..\data\test\move_directory2/test'
    util = OSUtilities()
    util.copy_files(destination, source, dirs=True)
    assert os.path.isdir(direct)
    shutil.rmtree(direct)
Example #3
0
def test_copy_files_files():
    """

    This function tests the OSUtilities.copy_files function to ensure that it
    correctly copies text file contents of a directory to a new directory
    """
    plat = platform.system()
    if plat == 'Darwin':
        source = '../data/test/move_directory3'
        destination = '../data/test/move_directory2'
        file1 = '../data/test/move_directory2/test1.txt'
        file2 = '../data/test/move_directory2/test2.txt'
    else:
        source = r'..\data\test\move_directory3'
        destination = r'..\data\test\move_directory2'
        file1 = r'..\data\test\move_directory2\test1.txt'
        file2 = r'..\data\test\move_directory2\test2.txt'
    util = OSUtilities()
    util.copy_files(destination, source, '.txt')
    assert os.path.isfile(file1)
    assert os.path.isfile(file2)
    os.remove(file1)
    os.remove(file2)