mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-05-21 21:05:05 +00:00
* feat: postgres tests * feat: mongo cutoff * feat: mongo cutoff * feat: adjust docs and compose files * fix: mini code mongo removals * fix: tests and k8s mongo stuff * feat: test fixes * fix: ruff * fix: vale * Potential fix for pull request finding 'CodeQL / Clear-text logging of sensitive information' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix: mini suggestions * vale lint fix 2 * fix: codeql columns thing * fix: test mongo * fix: tests coverage * feat: better tests 4 * feat: more tests * feat: decent coverage * fix: ruff fixes * fix: remove mongo mock * feat: enhance workflow engine and API routes; add document retrieval and source handling * feat: e2e tests * fix: mcp, mongo and more * fix: mini codeql warning * fix: agent chunk view * fix: mini issues * fix: more pg fixes * feat: postgres prep on start * feat: qa tests * fix: mini improvements * fix: tests --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Siddhant Rai <siddhant.rai.5686@gmail.com>
77 lines
2.6 KiB
Python
77 lines
2.6 KiB
Python
"""Tests for error paths in read_webpage tool."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import requests
|
|
|
|
|
|
class TestReadWebpageErrors:
|
|
def test_request_exception_returns_error_string(self):
|
|
from application.agents.tools.read_webpage import ReadWebpageTool
|
|
|
|
tool = ReadWebpageTool(config={})
|
|
with patch(
|
|
"application.agents.tools.read_webpage.validate_url",
|
|
return_value=None,
|
|
), patch(
|
|
"application.agents.tools.read_webpage.requests.get",
|
|
side_effect=requests.exceptions.RequestException("bad url"),
|
|
):
|
|
got = tool.execute_action(
|
|
"read_webpage", url="https://example.com/",
|
|
)
|
|
assert "Error fetching URL" in got
|
|
|
|
def test_generic_exception_returns_error_string(self):
|
|
from application.agents.tools.read_webpage import ReadWebpageTool
|
|
|
|
tool = ReadWebpageTool(config={})
|
|
with patch(
|
|
"application.agents.tools.read_webpage.validate_url",
|
|
return_value=None,
|
|
), patch(
|
|
"application.agents.tools.read_webpage.markdownify",
|
|
side_effect=RuntimeError("boom"),
|
|
), patch(
|
|
"application.agents.tools.read_webpage.requests.get",
|
|
) as mock_get:
|
|
mock_get.return_value.text = "<h1>hi</h1>"
|
|
mock_get.return_value.raise_for_status.return_value = None
|
|
got = tool.execute_action(
|
|
"read_webpage", url="https://example.com/",
|
|
)
|
|
assert "Error processing URL" in got
|
|
|
|
|
|
class TestBaseAgentMinorBranches:
|
|
"""Cover 2 missing lines in agents/base.py (116, 160)."""
|
|
|
|
def test_base_agent_with_llm_provided(self):
|
|
from application.agents.classic_agent import ClassicAgent
|
|
from unittest.mock import MagicMock
|
|
|
|
mock_llm = MagicMock()
|
|
mock_handler = MagicMock()
|
|
# Instantiating with llm+llm_handler skips the creator call paths
|
|
agent = ClassicAgent(
|
|
endpoint="ep", llm_name="openai", model_id="gpt-4",
|
|
api_key="k", llm=mock_llm, llm_handler=mock_handler,
|
|
)
|
|
assert agent.llm is mock_llm
|
|
assert agent.llm_handler is mock_handler
|
|
|
|
|
|
class TestWorkflowNodesMinor:
|
|
"""Cover line 44 in workflow_nodes.py (likely default params branch)."""
|
|
|
|
def test_bulk_create_empty_list_returns_empty(self, pg_conn):
|
|
from application.storage.db.repositories.workflow_nodes import (
|
|
WorkflowNodesRepository,
|
|
)
|
|
got = WorkflowNodesRepository(pg_conn).bulk_create(
|
|
"00000000-0000-0000-0000-000000000001",
|
|
1,
|
|
[],
|
|
)
|
|
assert got == []
|