diff --git a/src/tests/backend/common/database/test_database_base.py b/src/tests/backend/common/database/test_database_base.py index dbc7c55ae..128d26cf7 100644 --- a/src/tests/backend/common/database/test_database_base.py +++ b/src/tests/backend/common/database/test_database_base.py @@ -493,8 +493,8 @@ 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): + + with pytest.raises(ValueError, match="Test exception"): async with database: assert database.initialized is True # Raise an exception to test cleanup diff --git a/src/tests/backend/v4/config/test_settings.py b/src/tests/backend/v4/config/test_settings.py index 0a694d7db..44c8191e7 100644 --- a/src/tests/backend/v4/config/test_settings.py +++ b/src/tests/backend/v4/config/test_settings.py @@ -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 @@ -23,7 +20,7 @@ ) -class TestAzureConfig(unittest.TestCase): +class TestAzureConfig(TestCase): """Test cases for AzureConfig class.""" @patch('backend.v4.config.settings.config') @@ -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') @@ -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): @@ -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): @@ -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): @@ -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(task.cancelled()) async def test_wait_for_clarification_cancelled(self): """Test waiting for clarification when cancelled.""" @@ -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(task.cancelled()) def test_cleanup_approval(self): """Test cleanup approval.""" @@ -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): @@ -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): @@ -873,4 +872,4 @@ async def approve_task(): if __name__ == '__main__': - unittest.main() + main() diff --git a/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py b/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py index 9c5a5b761..974af8794 100644 --- a/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py +++ b/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py @@ -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