Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions src/tests/backend/common/database/test_database_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,18 @@ async def delete_team_agent(self, team_id, agent_name): pass
async def get_team_agent(self, team_id, agent_name): return None

database = MockDatabase()

with pytest.raises(ValueError):

exception_raised = False
try:
async with database:
assert database.initialized is True
# Raise an exception to test cleanup
raise ValueError("Test exception")
except ValueError:
exception_raised = True

# Even with exception, close should have been called
assert exception_raised is True
assert database.closed is True


Expand Down
27 changes: 13 additions & 14 deletions src/tests/backend/v4/config/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

import asyncio
import json
import os
import sys
import unittest
from unittest import IsolatedAsyncioTestCase
from unittest import TestCase, IsolatedAsyncioTestCase, main
from unittest.mock import AsyncMock, Mock, patch

# Environment variables are set by conftest.py
Expand All @@ -23,7 +20,7 @@
)


class TestAzureConfig(unittest.TestCase):
class TestAzureConfig(TestCase):
"""Test cases for AzureConfig class."""

@patch('backend.v4.config.settings.config')
Expand Down Expand Up @@ -76,7 +73,7 @@ def test_ad_token_provider(self, mock_config):
mock_credential.get_token.assert_called_once_with(mock_config.AZURE_COGNITIVE_SERVICES)


class TestAzureConfigAsync(unittest.IsolatedAsyncioTestCase):
class TestAzureConfigAsync(IsolatedAsyncioTestCase):
"""Async test cases for AzureConfig class."""

@patch('backend.v4.config.settings.AzureOpenAIChatClient')
Expand Down Expand Up @@ -106,7 +103,7 @@ async def test_create_chat_completion_service_reasoning_model(self, mock_client_
mock_client_class.assert_called_once()


class TestMCPConfig(unittest.TestCase):
class TestMCPConfig(TestCase):
"""Test cases for MCPConfig class."""

def test_mcp_config_creation(self):
Expand Down Expand Up @@ -151,7 +148,7 @@ def test_get_headers_with_none_token(self):
self.assertEqual(headers, {})


class TestTeamConfig(unittest.TestCase):
class TestTeamConfig(TestCase):
"""Test cases for TeamConfig class."""

def test_team_config_creation(self):
Expand Down Expand Up @@ -198,7 +195,7 @@ def test_overwrite_existing_team(self):
self.assertEqual(config.get_current_team(user_id), team_config2)


class TestOrchestrationConfig(unittest.IsolatedAsyncioTestCase):
class TestOrchestrationConfig(IsolatedAsyncioTestCase):
"""Test cases for OrchestrationConfig class."""

def test_orchestration_config_creation(self):
Expand Down Expand Up @@ -347,9 +344,10 @@ async def cancel_task():
cancel_task_handle = asyncio.create_task(cancel_task())

with self.assertRaises(asyncio.CancelledError):
await task
_ = await task

await cancel_task_handle
self.assertTrue(cancel_task_handle.done())

async def test_wait_for_clarification_cancelled(self):
"""Test waiting for clarification when cancelled."""
Expand All @@ -367,9 +365,10 @@ async def cancel_task():
cancel_task_handle = asyncio.create_task(cancel_task())

with self.assertRaises(asyncio.CancelledError):
await task
_ = await task

await cancel_task_handle
self.assertTrue(cancel_task_handle.done())

def test_cleanup_approval(self):
"""Test cleanup approval."""
Expand Down Expand Up @@ -404,7 +403,7 @@ def test_cleanup_clarification(self):
self.assertNotIn(request_id, config._clarification_events)


class TestConnectionConfig(unittest.IsolatedAsyncioTestCase):
class TestConnectionConfig(IsolatedAsyncioTestCase):
"""Test cases for ConnectionConfig class."""

def test_connection_config_creation(self):
Expand Down Expand Up @@ -745,7 +744,7 @@ def test_send_status_update_sync_no_connection(self):
mock_logger.warning.assert_called()


class TestGlobalInstances(unittest.TestCase):
class TestGlobalInstances(TestCase):
"""Test cases for global configuration instances."""

def test_global_instances_exist(self):
Expand Down Expand Up @@ -873,4 +872,4 @@ async def approve_task():


if __name__ == '__main__':
unittest.main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# Environment variables and paths are set by conftest.py
# Import the models (conftest.py handles path setup)
from backend.v4.models.models import MPlan, MStep, PlanStatus
from backend.v4.models.models import MPlan, PlanStatus

# Import the converter
from backend.v4.orchestration.helper.plan_to_mplan_converter import PlanToMPlanConverter
Expand Down
Loading