2023-11-29 18:32:07 +00:00
|
|
|
"""Integration test for Stack Exchange."""
|
2023-12-11 21:53:30 +00:00
|
|
|
from langchain_community.utilities import StackExchangeAPIWrapper
|
2023-11-29 18:32:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_call() -> None:
|
|
|
|
"""Test that call runs."""
|
2024-05-13 18:55:07 +00:00
|
|
|
stackexchange = StackExchangeAPIWrapper() # type: ignore[call-arg]
|
2023-11-29 18:32:07 +00:00
|
|
|
output = stackexchange.run("zsh: command not found: python")
|
|
|
|
assert output != "hello"
|
|
|
|
|
|
|
|
|
|
|
|
def test_failure() -> None:
|
|
|
|
"""Test that call that doesn't run."""
|
2024-05-13 18:55:07 +00:00
|
|
|
stackexchange = StackExchangeAPIWrapper() # type: ignore[call-arg]
|
2023-11-29 18:32:07 +00:00
|
|
|
output = stackexchange.run("sjefbsmnf")
|
|
|
|
assert output == "No relevant results found for 'sjefbsmnf' on Stack Overflow"
|
|
|
|
|
|
|
|
|
|
|
|
def test_success() -> None:
|
|
|
|
"""Test that call that doesn't run."""
|
2024-05-13 18:55:07 +00:00
|
|
|
stackexchange = StackExchangeAPIWrapper() # type: ignore[call-arg]
|
2023-11-29 18:32:07 +00:00
|
|
|
output = stackexchange.run("zsh: command not found: python")
|
|
|
|
assert "zsh: command not found: python" in output
|