예제 #1
0
def test_async_auto_create_directory(directory):
    directory = os.path.join(directory, 'folder', 'subfolder')
    handler = AsyncLocalFileHandler(base_path=directory, auto_make_dir=True)
    assert not os.path.exists(directory)

    handler.validate()

    assert os.path.exists(directory)
예제 #2
0
def test_async_error_when_no_directory(directory):
    directory = os.path.join(directory, 'folder', 'subfolder')
    handler = AsyncLocalFileHandler(base_path=directory)

    with pytest.raises(FilestorageConfigError) as err:
        handler.validate()

    assert directory.rstrip('/').rstrip('\\') in str(err.value)
    assert 'does not exist' in str(err.value)
예제 #3
0
def test_async_validate_when_no_sync(directory):
    directory = os.path.join(directory, 'folder', 'subfolder')
    handler = AsyncLocalFileHandler(
        base_path=directory, allow_sync_methods=False, auto_make_dir=True
    )
    assert not os.path.exists(directory)

    handler.validate()

    assert os.path.exists(directory)