langchain/tests/integration_tests/document_loaders/test_slack.py
vowelparrot bf0887c486
Add Slack Directory Loader (#2841)
Fixes linting issue from #2835 

Adds a loader for Slack Exports which can be a very valuable source of
knowledge to use for internal QA bots and other use cases.

```py
# Export data from your Slack Workspace first.
from langchain.document_loaders import SLackDirectoryLoader

SLACK_WORKSPACE_URL = "https://awesome.slack.com"

loader = ("Slack_Exports", SLACK_WORKSPACE_URL)
docs = loader.load()
```
2023-04-13 21:31:59 -07:00

24 lines
812 B
Python

"""Tests for the Slack directory loader"""
from pathlib import Path
from langchain.document_loaders import SlackDirectoryLoader
def test_slack_directory_loader() -> None:
"""Test Slack directory loader."""
file_path = Path(__file__).parent.parent / "examples/slack_export.zip"
loader = SlackDirectoryLoader(str(file_path))
docs = loader.load()
assert len(docs) == 5
def test_slack_directory_loader_urls() -> None:
"""Test workspace URLS are passed through in the SlackDirectoryloader."""
file_path = Path(__file__).parent.parent / "examples/slack_export.zip"
workspace_url = "example_workspace.com"
loader = SlackDirectoryLoader(str(file_path), workspace_url)
docs = loader.load()
for doc in docs:
assert doc.metadata["source"].startswith(workspace_url)