langchain/tests/unit_tests/document_loaders
os1ma 1366d070fc
Add path validation to DirectoryLoader (#5327)
# Add path validation to DirectoryLoader

This PR introduces a minor adjustment to the DirectoryLoader by adding
validation for the path argument. Previously, if the provided path
didn't exist or wasn't a directory, DirectoryLoader would return an
empty document list due to the behavior of the `glob` method. This could
potentially cause confusion for users, as they might expect a
file-loading error instead.

So, I've added two validations to the load method of the
DirectoryLoader:

- Raise a FileNotFoundError if the provided path does not exist
- Raise a ValueError if the provided path is not a directory

Due to the relatively small scope of these changes, a new issue was not
created.

## Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on
network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests,
lint
etc:


https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

## Who can review?

Community members can review the PR once tests pass. Tag
maintainers/contributors who might be interested:

@eyurtsev
2023-05-28 15:31:23 -04:00
..
blob_loaders fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
loaders fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
parsers Add html parsers (#4874) 2023-05-17 22:39:11 -04:00
sample_documents Bibtex integration for document loader and retriever (#5137) 2023-05-25 00:21:31 -07:00
test_docs Allow readthedoc loader to pass custom html tag (#5175) 2023-05-24 10:40:27 -07:00
__init__.py fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
test_base.py fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
test_bibtex.py Bibtex integration for document loader and retriever (#5137) 2023-05-25 00:21:31 -07:00
test_bshtml.py Add html parsers (#4874) 2023-05-17 22:39:11 -04:00
test_confluence.py Add Confluence Loader unit tests (#3333) 2023-05-16 15:17:07 -07:00
test_csv_loader.py fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
test_detect_encoding.py feat #4479: TextLoader auto detect encoding and improved exceptions (#4927) 2023-05-18 09:55:14 -04:00
test_directory.py Add path validation to DirectoryLoader (#5327) 2023-05-28 15:31:23 -04:00
test_evernote_loader.py feature/4493 Improve Evernote Document Loader (#4577) 2023-05-19 14:28:17 -07:00
test_generic_loader.py Add a generic document loader (#4875) 2023-05-17 22:38:55 -04:00
test_json_loader.py fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
test_psychic.py Harrison/psychic (#5063) 2023-05-21 09:13:20 -07:00
test_readthedoc.py Allow readthedoc loader to pass custom html tag (#5175) 2023-05-24 10:40:27 -07:00
test_telegram.py fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
test_web_base.py fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00
test_youtube.py fix(document_loaders/telegram): fix pandas calls + add tests (#4806) 2023-05-16 14:35:25 -07:00