def test_can_append(blockchain_path, base_filename, optimized_file_path):
    fss = PathOptimizedFileSystemStorage(base_path=blockchain_path)
    fss.save(base_filename, b'\x08Test')
    assert os.path.isfile(optimized_file_path)
    with open(optimized_file_path, 'rb') as fo:
        assert fo.read() == b'\x08Test'

    fss.append(base_filename, b'\x09\x0aAPPEND')
    with open(optimized_file_path, 'rb') as fo:
        assert fo.read() == b'\x08Test\x09\x0aAPPEND'
def test_can_append_to_optimized_path(blockchain_path):
    storage = PathOptimizedFileSystemStorage(blockchain_path)
    with patch('thenewboston_node.business_logic.storages.file_system.FileSystemStorage.append') as append_mock:
        storage.append('parent/file.txt', b'test data')

    append_mock.assert_called_once_with('parent/f/i/l/e/file.txt', b'test data', is_final=False)