Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/tests/agent/test_checklist_verifier.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

import unittest
from unittest.mock import MagicMock, patch

from agent.nodes import checklist_verifier
from agent.state import OverallState


class TestChecklistVerifier(unittest.TestCase):
def setUp(self):
self.mock_config = {"configurable": {"thread_id": "1", "answer_model": "test-model"}}
Expand Down
8 changes: 5 additions & 3 deletions backend/tests/agent/test_middleware_security.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pytest
from unittest.mock import MagicMock
from fastapi.testclient import TestClient

import pytest
from fastapi import Request, Response
from agent.app import app, ContentSizeLimitMiddleware
from fastapi.testclient import TestClient

from agent.app import ContentSizeLimitMiddleware, app

# Initialize TestClient with a trusted host (localhost) to pass TrustedHostMiddleware
client = TestClient(app, base_url="http://localhost")
Expand Down
14 changes: 7 additions & 7 deletions backend/tests/agent/test_orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
- Orchestrated graph construction
"""

from typing import Any, Dict
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from unittest.mock import MagicMock, patch, AsyncMock
from typing import Dict, Any
from langchain_core.messages import AIMessage, HumanMessage

from agent.orchestration import (
ToolRegistry,
AgentPool,
ToolSpec,
AgentSpec,
ToolRegistry,
ToolSpec,
build_orchestrated_graph,
create_coordinator_node,
create_task_router,
build_orchestrated_graph,
)
from agent.state import OverallState
from langchain_core.messages import HumanMessage, AIMessage


# =============================================================================
# ToolRegistry Tests
Expand Down
8 changes: 5 additions & 3 deletions backend/tests/agent/test_rag.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

import pytest
import importlib
import sys
import numpy as np
from unittest.mock import MagicMock, patch
import importlib

import numpy as np
import pytest


# Fixture to mock dependencies before importing the module under test
@pytest.fixture
Expand Down
6 changes: 4 additions & 2 deletions backend/tests/agent/test_rate_limiter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""Tests for RateLimiter."""

import unittest
from datetime import date, datetime, timedelta
from unittest.mock import MagicMock, patch
from datetime import datetime, date, timedelta
from zoneinfo import ZoneInfo
from agent.rate_limiter import RateLimiter, PACIFIC_TZ

from agent.rate_limiter import PACIFIC_TZ, RateLimiter


class TestRateLimiter(unittest.TestCase):
def test_daily_reset_logic(self):
Expand Down
6 changes: 4 additions & 2 deletions backend/tests/agent/test_rate_limiter_proxy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from unittest.mock import patch

import pytest
from fastapi.testclient import TestClient
from unittest.mock import patch
from starlette.responses import PlainTextResponse

from agent.app import app
from agent.security import RateLimitMiddleware
from starlette.responses import PlainTextResponse

# ----------------------------------------------------------------------
# 1. Integration Test with FastAPI App
Expand Down
13 changes: 8 additions & 5 deletions backend/tests/agent/test_supervisor_llm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pytest
from unittest.mock import patch, MagicMock
import dataclasses
from agent.state import OverallState
from unittest.mock import MagicMock, patch

import pytest
from langchain_core.messages import AIMessage
from langchain_core.runnables import RunnableConfig

from agent.graphs import supervisor
from agent.graphs.supervisor import compress_context
from langchain_core.runnables import RunnableConfig
from langchain_core.messages import AIMessage
from agent.state import OverallState


@pytest.fixture
def enable_compression():
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
This module provides reusable fixtures that can be used across all test files.
Fixtures are designed to be path-insensitive and robust to minor code changes.
"""
import os
import pathlib
import sys
from typing import Any, Dict, List
from types import SimpleNamespace
from typing import Any, Dict, List

import pytest
import os

# Set dummy API key before any imports that might use it
os.environ["GEMINI_API_KEY"] = "dummy_key_for_tests"
Expand Down
10 changes: 6 additions & 4 deletions backend/tests/evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
structured grading of agent outputs using a Judge LLM (Gemini 2.5 Pro).
"""

from typing import Dict, Any, Optional, List
from pydantic import BaseModel, Field
from langchain_google_genai import ChatGoogleGenerativeAI
import os
from typing import Any, Dict, List, Optional

from langchain_core.prompts import ChatPromptTemplate
from langchain_google_genai import ChatGoogleGenerativeAI
from pydantic import BaseModel, Field

from agent.models import GEMINI_PRO
import os

# Module-level cache for the judge model instance
_judge_model_cache: Optional[ChatGoogleGenerativeAI] = None
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from agent.configuration import Configuration
from agent.models import (
TEST_MODEL,
GEMINI_PRO,
DEFAULT_ANSWER_MODEL,
DEFAULT_QUERY_MODEL,
DEFAULT_REFLECTION_MODEL,
DEFAULT_ANSWER_MODEL,
GEMINI_PRO,
TEST_MODEL,
)


Expand Down
7 changes: 4 additions & 3 deletions backend/tests/test_gemma_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
3. Robustness against token limit behaviors typical of smaller models.
"""

from unittest.mock import ANY, MagicMock, patch

import pytest
from unittest.mock import MagicMock, patch, ANY
from langchain_core.runnables import RunnableConfig
from langchain_core.messages import AIMessage, HumanMessage
from langchain_core.runnables import RunnableConfig

from agent.models import GEMMA_2_27B_IT, GEMMA_3_27B_IT
from agent.nodes import (
denoising_refiner,
generate_plan,
web_research,
denoising_refiner,
)
from agent.state import OverallState

Expand Down
14 changes: 11 additions & 3 deletions backend/tests/test_graph_mock.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from unittest.mock import MagicMock, Mock, patch

import pytest
from unittest.mock import Mock, patch, MagicMock
from agent.nodes import generate_plan, web_research, reflection, denoising_refiner, load_context
from langchain_core.messages import HumanMessage, AIMessage
from langchain_core.messages import AIMessage, HumanMessage

from agent.models import TEST_MODEL
from agent.nodes import (
denoising_refiner,
generate_plan,
load_context,
reflection,
web_research,
)

TEST_MODEL = "gemma-3-27b-it"

Expand Down
5 changes: 3 additions & 2 deletions backend/tests/test_input_validation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import unittest
import sys
import os
import sys
import unittest

# Add backend/src to python path
sys.path.append(os.path.join(os.path.dirname(__file__), "../src"))

from agent.app import InvokeRequest


class TestDoS(unittest.TestCase):
def test_large_initial_query_count(self):
"""
Expand Down
5 changes: 4 additions & 1 deletion backend/tests/test_ipv6_rate_limit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

from unittest.mock import AsyncMock, MagicMock

import pytest
from unittest.mock import MagicMock, AsyncMock

from agent.security import RateLimitMiddleware


class MockApp:
pass

Expand Down
11 changes: 9 additions & 2 deletions backend/tests/test_kaggle_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
Unit tests for backend/examples/kaggle_integration.py
"""

from unittest.mock import MagicMock, patch

import pytest
from unittest.mock import patch, MagicMock
from examples.kaggle_integration import KaggleModelLoader, KaggleHuggingFaceClient, SimpleReActAgent, BaseLLMClient

from examples.kaggle_integration import (
BaseLLMClient,
KaggleHuggingFaceClient,
KaggleModelLoader,
SimpleReActAgent,
)

# =============================================================================
# Tests for KaggleModelLoader
Expand Down
4 changes: 3 additions & 1 deletion backend/tests/test_mcp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from unittest.mock import MagicMock, patch, AsyncMock

from agent.tools_and_schemas import get_tools_from_mcp

# Fine-grained implementation guide for MCP Tests:
Expand Down
4 changes: 3 additions & 1 deletion backend/tests/test_mcp_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import unittest
from unittest import mock
from agent.mcp_config import load_mcp_settings, validate, MCPSettings

from agent.mcp_config import MCPSettings, load_mcp_settings, validate


class TestMCPSettings(unittest.TestCase):
def test_default_settings(self):
Expand Down
7 changes: 5 additions & 2 deletions backend/tests/test_mcp_tools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import asyncio
import pytest
from unittest.mock import MagicMock, patch
from agent.tools_and_schemas import get_tools_from_mcp

import pytest

from agent.mcp_config import MCPSettings
from agent.tools_and_schemas import get_tools_from_mcp


@pytest.mark.asyncio
async def test_get_tools_from_mcp_disabled():
Expand Down
8 changes: 5 additions & 3 deletions backend/tests/test_memory_tools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import unittest
from agent.memory_tools import save_plan_tool, load_plan_tool
from agent.persistence import PLAN_DIR
import os
import shutil
import unittest

from agent.memory_tools import load_plan_tool, save_plan_tool
from agent.persistence import PLAN_DIR


class TestMemoryTools(unittest.TestCase):
def setUp(self):
Expand Down
24 changes: 13 additions & 11 deletions backend/tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@
- Edge cases and error handling
"""

import pytest
import dataclasses
from unittest.mock import Mock, patch, MagicMock, AsyncMock
from langchain_core.runnables import RunnableConfig
from unittest.mock import AsyncMock, MagicMock, Mock, patch

import pytest
from langchain_core.messages import AIMessage, HumanMessage
from langchain_core.runnables import RunnableConfig

from config.app_config import AppConfig, config as real_config
from agent.state import OverallState
from agent import nodes
from agent.models import TEST_MODEL
from agent.nodes import (
content_reader,
denoising_refiner,
execution_router,
generate_plan,
planning_mode,
planning_wait,
web_research,
validate_web_results,
reflection,
denoising_refiner,
content_reader,
select_next_task,
execution_router,
validate_web_results,
web_research,
)
from agent.models import TEST_MODEL
from agent.state import OverallState
from config.app_config import AppConfig
from config.app_config import config as real_config


# Fixtures
Expand Down
1 change: 1 addition & 0 deletions backend/tests/test_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
import json
import os

import pytest


Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
state configurations and flags.
"""
import pytest
from agent.nodes import planning_mode, planning_router, planning_wait

from agent.nodes import planning_mode, planning_router, planning_wait

# =============================================================================
# Helper function
Expand Down
5 changes: 4 additions & 1 deletion backend/tests/test_proxy_security.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@

from unittest.mock import AsyncMock, MagicMock

import pytest
from unittest.mock import MagicMock, AsyncMock
from starlette.responses import PlainTextResponse

from agent.security import RateLimitMiddleware


@pytest.mark.asyncio
async def test_proxy_security_default_secure():
"""Verify that by default (trust_proxy_headers=False), X-Forwarded-For is ignored."""
Expand Down
5 changes: 4 additions & 1 deletion backend/tests/test_rag_nodes_mock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pytest
from unittest.mock import Mock, patch

import pytest

from agent.rag_nodes import rag_retrieve


@pytest.fixture
def mock_rag_state():
return {
Expand Down
Loading
Loading