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

    This function tests the OSUtilities.delete_file function to ensure that it correctly
    deletes a file
    """
    util = OSUtilities()
    plat = platform.system()
    if plat == 'Darwin':
        file = '../data/test/delete_test.txt'
    else:
        file = r'..\data\test\delete_test.txt'
    util.delete_file(file)
    assert not os.path.isfile(file)
    if not os.path.isfile(file):
        util.create_file(file)
Example #2
0
def test_create_file():
    """

    This function tests the OSUtilities.create_file function to ensure that it
    correctly creates an ASCII based text file
    """
    util = OSUtilities()
    plat = platform.system()
    if plat == 'Darwin':
        file = '../data/test/create_file_test.txt'
    else:
        file = r'..\data\test\create_file_test.txt'
    util.create_file(file)
    assert os.path.isfile(file)
    if os.path.isfile(file):
        os.remove(file)
Example #3
0
def test_remove_populated_directory():
    """

    This function tests the OSUtilities.remove_populated_directory function to determine
    if it correctly removes a populated directory
    """
    util = OSUtilities()
    plat = platform.system()
    if plat == 'Darwin':
        directory = '../data/test/populated_dir1'
        file = '../data/test/populated_dir1/test.txt'
    else:
        directory = r'../data/test/populated_dir1'
        file = r'../data/test/populated_dir1/test.txt'
    util.delete_populated_directory(directory)
    assert not os.path.isdir(directory)
    if not os.path.isdir(directory):
        os.mkdir(directory)
        util.create_file(file)