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)
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)
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)