Example #1
0
def test_file_system_move():
    """
    Test content being moved and sizes being incremented and decremented
    """

    file_system = FileSystem()

    file_system.create('drive', 'a', '')

    folder_b_source = file_system.create('folder', 'b', 'a')

    folder_b_target = file_system.create('folder', 'bb', 'a')

    text_c = file_system.create('text', 'c', 'a\\b')

    test_string = 'teststring'
    file_system.write_to_file(text_c.path, test_string)

    file_system.move(text_c.path, folder_b_target.path)

    assert 'c' not in folder_b_source.get_names()
    assert 'c' in folder_b_target.get_names()
    assert folder_b_source.size == 0
    assert folder_b_target.size == len(test_string)
Example #2
0
def main():
    """
    Demonstrates the FileSystem implementation.
    Executes methods and prints the file system structure after each operation.
    """

    print('\n##############')
    print('# File System')
    print('##############\n')

    print('Package in /file_system\n')

    print('Pytest suite in /tests\n')

    print('###################')
    print('# File System Demo')
    print('###################\n')

    print('1. Creating File System')
    file_system = FileSystem()

    print('2. Adding DriveA to Root')
    file_system.create('drive', 'DriveA', '')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('3. Adding DriveB to Root')
    file_system.create('drive', 'DriveB', '')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('4. Adding FolderA to DriveA')
    file_system.create('folder', 'FolderA', 'DriveA')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('5. Adding FolderB to DriveB')
    folder_b = file_system.create('folder', 'FolderB', 'DriveB')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('6. Adding FolderC to FolderB')
    file_system.create('folder', 'FolderC', 'DriveB\\FolderB')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('7. Adding ZipA to DriveA')
    zip_a = file_system.create('zip', 'ZipA', 'DriveA')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('8. Adding TextA to FolderC')
    text_a = file_system.create('text', 'TextA', 'DriveB\\FolderB\\FolderC')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('9. Updating TextA Content with \'testabcd\'')
    file_system.write_to_file(text_a.path, 'testabcd')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('10. Adding TextB to ZipA')
    text_b = file_system.create('text', 'TextB', 'DriveA\\ZipA')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('11. Updating TextB Content with \'testabcdtestabcd\'')
    file_system.write_to_file(text_b.path, 'testabcdtestabcd')
    print('Current File System Structure: \n' + str(file_system))
    print()

    print('12. Move FolderB into ZipA')
    file_system.move(folder_b.path, zip_a.path)
    print('Current File System Structure: \n' + str(file_system))
    print()