Merge pull request #172 from christianlouis/copilot/fix-deprecated-pydantic-methods
fix: replace deprecated Pydantic .dict() with .model_dump() and fix db.add() AsyncMock warnings
This commit is contained in:
@@ -172,9 +172,8 @@ class TestConfigServiceSet:
|
||||
mock_result.scalar_one_or_none.return_value = None
|
||||
|
||||
mock_db = AsyncMock()
|
||||
mock_db.add = MagicMock()
|
||||
mock_db.execute.return_value = mock_result
|
||||
|
||||
# The method will call db.add() and db.commit()
|
||||
await ConfigService.set(
|
||||
"SMTP_HOST", "new.host.com", db=mock_db, category="smtp"
|
||||
)
|
||||
|
||||
@@ -77,6 +77,8 @@ def _mock_session_maker():
|
||||
is usable as ``async with session_maker_mock() as db:``.
|
||||
"""
|
||||
session = AsyncMock()
|
||||
# db.add() is synchronous in SQLAlchemy; prevent "coroutine never awaited" warnings
|
||||
session.add = MagicMock()
|
||||
|
||||
# Make the session usable as an async context manager
|
||||
ctx = AsyncMock()
|
||||
|
||||
Reference in New Issue
Block a user