feat: Centralize database connection settings and deprecate old parameters (#5960)
* feat: Add database connection settings configuration Introduce a new `db_connection_settings` dictionary to centralize database connection parameters. Mark `pool_size` and `max_overflow` as deprecated, recommending the use of the new configuration dictionary instead. * refactor: Improve database connection settings handling Add a method to build connection kwargs that merges deprecated settings with the new db_connection_settings, providing a more flexible and backwards-compatible approach to database connection configuration. * fix: Resolve SQLAlchemy async engine pool configuration for SQLite Explicitly set AsyncAdaptedQueuePool for SQLite connections to address potential async engine configuration issues. This ensures proper pool handling when creating database connections, particularly for SQLite databases. * test: Add mock testing for bundle loading from GitHub URLs Enhance test coverage for `load_bundles_from_urls()` by introducing a mock fixture to simulate zip file content and mocking HTTP requests. This allows testing the bundle loading mechanism without making actual network calls. * [autofix.ci] apply automated fixes * test: Enhance GitHub URL detection test with mocking and improved coverage Refactor `test_detect_github_url` to use AsyncMock and patch for more robust testing of GitHub URL detection, including verification of API calls and handling of different URL scenarios. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
5fd91854b8
commit
e0f5cfccd8
3 changed files with 61 additions and 11 deletions
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import uuid
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import anyio
|
||||
import pytest
|
||||
|
|
@ -212,7 +213,20 @@ async def test_refresh_starter_projects():
|
|||
],
|
||||
)
|
||||
async def test_detect_github_url(url, expected):
|
||||
assert await detect_github_url(url) == expected
|
||||
# Mock the GitHub API response for the default branch case
|
||||
mock_response = AsyncMock()
|
||||
mock_response.json = lambda: {"default_branch": "main"} # Not async, just returns a dict
|
||||
mock_response.raise_for_status.return_value = None
|
||||
|
||||
with patch("httpx.AsyncClient.get", return_value=mock_response) as mock_get:
|
||||
result = await detect_github_url(url)
|
||||
assert result == expected
|
||||
|
||||
# Verify the API call was only made for GitHub repo URLs
|
||||
if "github.com" in url and not any(x in url for x in ["/tree/", "/releases/", "/commit/"]):
|
||||
mock_get.assert_called_once()
|
||||
else:
|
||||
mock_get.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue