diff --git a/tests/test_api_settings.py b/tests/test_api_settings.py index de9c65fe..8512387d 100644 --- a/tests/test_api_settings.py +++ b/tests/test_api_settings.py @@ -226,7 +226,7 @@ class TestListCredentials: for key in SETTING_METADATA: setattr(mock_settings, key, None) - result = asyncio.get_event_loop().run_until_complete(list_credentials(mock_request, mock_db, mock_admin)) + result = asyncio.run(list_credentials(mock_request, mock_db, mock_admin)) returned_keys = {c["key"] for c in result["credentials"]} sensitive_keys = {k for k, v in SETTING_METADATA.items() if v.get("sensitive")} @@ -247,7 +247,7 @@ class TestListCredentials: with patch("app.api.settings.settings") as mock_settings: mock_settings.openai_api_key = "sk-env-key" - result = asyncio.get_event_loop().run_until_complete(list_credentials(mock_request, mock_db, mock_admin)) + result = asyncio.run(list_credentials(mock_request, mock_db, mock_admin)) openai_entry = next(c for c in result["credentials"] if c["key"] == "openai_api_key") assert openai_entry["source"] == "db" @@ -268,7 +268,7 @@ class TestListCredentials: with patch("app.api.settings.settings") as mock_settings: mock_settings.openai_api_key = "sk-env-key" - result = asyncio.get_event_loop().run_until_complete(list_credentials(mock_request, mock_db, mock_admin)) + result = asyncio.run(list_credentials(mock_request, mock_db, mock_admin)) openai_entry = next(c for c in result["credentials"] if c["key"] == "openai_api_key") assert openai_entry["source"] == "env" @@ -289,7 +289,7 @@ class TestListCredentials: with patch("app.api.settings.settings") as mock_settings: mock_settings.openai_api_key = None - result = asyncio.get_event_loop().run_until_complete(list_credentials(mock_request, mock_db, mock_admin)) + result = asyncio.run(list_credentials(mock_request, mock_db, mock_admin)) openai_entry = next(c for c in result["credentials"] if c["key"] == "openai_api_key") assert openai_entry["configured"] is False @@ -311,7 +311,7 @@ class TestListCredentials: # Most keys will be None, one will be set via db_settings mock mock_settings.openai_api_key = "sk-key" - result = asyncio.get_event_loop().run_until_complete(list_credentials(mock_request, mock_db, mock_admin)) + result = asyncio.run(list_credentials(mock_request, mock_db, mock_admin)) assert result["total"] == len(result["credentials"]) assert result["configured_count"] + result["unconfigured_count"] == result["total"] @@ -331,7 +331,7 @@ class TestListCredentials: mock_admin = {"is_admin": True} with pytest.raises(HTTPException) as exc_info: - asyncio.get_event_loop().run_until_complete(list_credentials(mock_request, mock_db, mock_admin)) + asyncio.run(list_credentials(mock_request, mock_db, mock_admin)) assert exc_info.value.status_code == 500 def test_list_credentials_endpoint_requires_admin(self, client): @@ -354,7 +354,7 @@ class TestListCredentials: with patch("app.api.settings.settings") as mock_settings: mock_settings.openai_api_key = None - result = asyncio.get_event_loop().run_until_complete(list_credentials(mock_request, mock_db, mock_admin)) + result = asyncio.run(list_credentials(mock_request, mock_db, mock_admin)) for cred in result["credentials"]: assert "key" in cred diff --git a/tests/test_cors.py b/tests/test_cors.py index ae9a4025..9357c21a 100644 --- a/tests/test_cors.py +++ b/tests/test_cors.py @@ -169,12 +169,9 @@ def test_cors_parse_comma_separated_origins(): original = os.environ.get("CORS_ALLOWED_ORIGINS") os.environ["CORS_ALLOWED_ORIGINS"] = "https://app.example.com,https://admin.example.com" try: - from importlib import reload + from app.config import Settings - import app.config as config_module - - reload(config_module) - test_settings = config_module.Settings( + test_settings = Settings( database_url="sqlite:///:memory:", redis_url="redis://localhost:6379/0", openai_api_key="test-key", @@ -204,12 +201,9 @@ def test_cors_single_origin_string_to_list(): original = os.environ.get("CORS_ALLOWED_ORIGINS") os.environ["CORS_ALLOWED_ORIGINS"] = "https://app.example.com" try: - from importlib import reload + from app.config import Settings - import app.config as config_module - - reload(config_module) - test_settings = config_module.Settings( + test_settings = Settings( database_url="sqlite:///:memory:", redis_url="redis://localhost:6379/0", openai_api_key="test-key",