Skip to content
Merged
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: 0 additions & 2 deletions src/tests/backend/auth/test_auth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import pytest
import base64
import json
import logging
import sys
import os
import importlib.util
from unittest.mock import patch, MagicMock

# Add the source root directory to the Python path for imports
Expand Down
3 changes: 0 additions & 3 deletions src/tests/backend/common/config/test_app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import os
import logging
from unittest.mock import patch, MagicMock, AsyncMock
from azure.identity import DefaultAzureCredential, ManagedIdentityCredential
from azure.cosmos import CosmosClient
from azure.ai.projects.aio import AIProjectClient

# Add the source root directory to the Python path for imports
import sys
Expand Down
4 changes: 1 addition & 3 deletions src/tests/backend/common/database/test_cosmosdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import logging
import sys
import os
from typing import Any, Dict, List, Optional
from unittest.mock import AsyncMock, MagicMock, Mock, patch
from unittest.mock import AsyncMock, Mock, patch
import pytest
import uuid

# Add the backend directory to the Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend'))
Expand Down
4 changes: 2 additions & 2 deletions src/tests/backend/common/database/test_database_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import sys
import os
from abc import ABC, abstractmethod
from abc import ABC
from typing import Any, Dict, List, Optional, Type
from unittest.mock import AsyncMock, Mock, patch
from unittest.mock import Mock
import pytest

# Add the backend directory to the Python path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import logging
import sys
import os
from typing import Optional
from unittest.mock import AsyncMock, Mock, patch, MagicMock
from unittest.mock import AsyncMock, Mock, patch
import pytest

# Add the backend directory to the Python path
Expand Down
2 changes: 1 addition & 1 deletion src/tests/backend/common/utils/test_event_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import sys
import os
from unittest.mock import Mock, patch, MagicMock
from unittest.mock import Mock, patch
import pytest

# Mock external dependencies at module level
Expand Down
2 changes: 1 addition & 1 deletion src/tests/backend/common/utils/test_otlp_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
import os
from unittest.mock import Mock, patch, MagicMock, call
from unittest.mock import Mock, patch, call
import pytest

# Mock external dependencies at module level
Expand Down
4 changes: 1 addition & 3 deletions src/tests/backend/common/utils/test_utils_af.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Unit tests for utils_af module."""

import logging
import sys
import os
import uuid
from unittest.mock import Mock, patch, AsyncMock, MagicMock
from unittest.mock import Mock, patch, AsyncMock
import pytest

# Add the backend directory to the Python path
Expand Down
5 changes: 1 addition & 4 deletions src/tests/backend/common/utils/test_utils_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
This module tests the utility functions for agent ID generation and database operations.
"""

import logging
import string
import sys
import unittest
Expand Down Expand Up @@ -33,10 +32,8 @@
sys.modules['common.models'] = Mock()
sys.modules['common.models.messages_af'] = Mock()

import pytest

from backend.common.database.database_base import DatabaseBase
from backend.common.models.messages_af import CurrentTeamAgent, DataType, TeamConfiguration
from backend.common.models.messages_af import CurrentTeamAgent, TeamConfiguration
from backend.common.utils.utils_agents import (
generate_assistant_id,
get_database_team_agent_id,
Expand Down
7 changes: 0 additions & 7 deletions src/tests/backend/common/utils/test_utils_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@

import json
import locale
import logging
import unittest
import sys
import os
from datetime import datetime
from typing import Optional
from unittest.mock import Mock, patch

import pytest

# Add the backend directory to the Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend'))

Expand Down Expand Up @@ -90,9 +86,6 @@ def mock_parse(date_str):
import re as real_re
utils_date_module.re = real_re

# Import dateutil.parser after mocking to avoid import errors
from dateutil import parser


class TestFormatDateForUser(unittest.TestCase):
"""Test cases for format_date_for_user function."""
Expand Down
4 changes: 1 addition & 3 deletions src/tests/backend/middleware/test_health_check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Unit tests for backend.middleware.health_check module."""
import asyncio
import logging
from unittest.mock import Mock, patch, AsyncMock, MagicMock
from unittest.mock import Mock, patch, AsyncMock
import pytest

# Import the module under test
Expand Down
1 change: 0 additions & 1 deletion src/tests/backend/v4/api/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys
import unittest
from unittest.mock import Mock, patch
import asyncio

# Set up environment
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', 'backend'))
Expand Down
3 changes: 1 addition & 2 deletions src/tests/backend/v4/callbacks/test_global_debug.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Unit tests for backend.v4.callbacks.global_debug module."""
import sys
from unittest.mock import Mock, patch
import pytest
from unittest.mock import Mock

# Mock the dependencies before importing the module under test
sys.modules['azure'] = Mock()
Expand Down
5 changes: 1 addition & 4 deletions src/tests/backend/v4/callbacks/test_response_handlers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"""Unit tests for response_handlers module."""

import asyncio
import logging
import sys
import os
import time
from unittest.mock import Mock, patch, AsyncMock, MagicMock
from unittest.mock import Mock, patch, AsyncMock
import pytest

# Add the backend directory to the Python path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import sys
import importlib.util
from unittest.mock import patch, MagicMock, AsyncMock, Mock
from typing import Any, Dict, Optional, Union
import aiohttp
from aiohttp import ClientTimeout, ClientSession

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@

import pytest
import os
import re
import logging
import aiohttp
import sys
import importlib.util
from unittest.mock import patch, MagicMock, AsyncMock, Mock
from typing import Any, Dict, List
from unittest.mock import patch, MagicMock, AsyncMock
from typing import Any, Dict

# Add backend directory to sys.path for imports
current_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
6 changes: 2 additions & 4 deletions src/tests/backend/v4/common/services/test_mcp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
import sys
import asyncio
import importlib.util
from unittest.mock import patch, MagicMock, AsyncMock, Mock
from typing import Any, Dict, Optional
import aiohttp
from aiohttp import ClientTimeout, ClientSession, ClientError
from unittest.mock import patch, MagicMock
from aiohttp import ClientError

# Add the src directory to sys.path for proper import
src_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')
Expand Down
4 changes: 2 additions & 2 deletions src/tests/backend/v4/common/services/test_plan_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import json
import logging
import importlib.util
from unittest.mock import patch, MagicMock, AsyncMock, Mock
from typing import Any, Dict, Optional, List
from unittest.mock import patch, MagicMock, AsyncMock
from typing import Any, List
from dataclasses import dataclass

# Add the src directory to sys.path for proper import
Expand Down
6 changes: 1 addition & 5 deletions src/tests/backend/v4/common/services/test_team_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
import os
import sys
import asyncio
import json
import logging
import uuid
import importlib.util
from unittest.mock import patch, MagicMock, AsyncMock, Mock
from typing import Any, Dict, Optional, List, Tuple
from dataclasses import dataclass
from unittest.mock import patch, MagicMock, AsyncMock
from datetime import datetime, timezone

# Add the src directory to sys.path for proper import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio
import logging
import sys
from unittest.mock import Mock, patch, AsyncMock, MagicMock
from unittest.mock import Mock, patch, AsyncMock
import pytest

# Mock the dependencies before importing the module under test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"""Unit tests for backend.v4.magentic_agents.foundry_agent module."""

import asyncio
import logging
import sys
import os
import time
from unittest.mock import Mock, patch, AsyncMock, MagicMock, call
from unittest.mock import Mock, patch, AsyncMock
import pytest

# Add the backend directory to the Python path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Unit tests for backend.v4.magentic_agents.magentic_agent_factory module."""
import asyncio
import json
import logging
import sys
from types import SimpleNamespace
from unittest.mock import Mock, patch, AsyncMock, MagicMock
from unittest.mock import Mock, AsyncMock
import pytest

# Mock the dependencies before importing the module under test
Expand Down
10 changes: 4 additions & 6 deletions src/tests/backend/v4/magentic_agents/test_proxy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import time
import uuid
from unittest.mock import Mock, patch, AsyncMock, MagicMock
from unittest.mock import Mock, patch, AsyncMock
import pytest

# Mock the dependencies before importing the module under test
Expand Down Expand Up @@ -57,7 +57,7 @@


# Now import the module under test
from backend.v4.magentic_agents.proxy_agent import ProxyAgent, create_proxy_agent
import backend.v4.magentic_agents.proxy_agent


class TestProxyAgentComplexScenarios:
Expand Down Expand Up @@ -123,9 +123,8 @@ def test_extract_logic(input_val):

def test_timeout_and_error_scenarios(self):
"""Test timeout and error handling scenarios."""
import asyncio




# Test that timeout logic would work
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
Expand Down Expand Up @@ -880,7 +879,6 @@ async def mock_wait_with_error_handling(request_id):
mock_orchestration_config.clarifications = {"test-request": None}

# This would test each error path
import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
import sys
import unittest
import re

# Set up environment variables (removed manual path modification as pytest config handles it)
os.environ.update({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
"""

import asyncio
import logging
import os
import sys
import unittest
from typing import Any, Optional
from unittest.mock import Mock, AsyncMock, patch

import pytest

# Add the backend directory to the Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import logging
import os
import sys
import uuid
from typing import List, Optional
from unittest import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, Mock, patch, MagicMock

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

# Add the backend directory to the Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend'))
Expand Down Expand Up @@ -442,7 +438,7 @@ async def test_get_current_or_new_orchestration_new(self):
mock_workflow = Mock()
mock_init.return_value = mock_workflow

result = await OrchestrationManager.get_current_or_new_orchestration(
await OrchestrationManager.get_current_or_new_orchestration(
user_id=self.test_user_id,
team_config=self.test_team_config,
team_switched=False,
Expand All @@ -466,7 +462,7 @@ async def test_get_current_or_new_orchestration_team_switched(self):
mock_new_workflow = Mock()
mock_init.return_value = mock_new_workflow

result = await OrchestrationManager.get_current_or_new_orchestration(
await OrchestrationManager.get_current_or_new_orchestration(
user_id=self.test_user_id,
team_config=self.test_team_config,
team_switched=True,
Expand Down