From d953564986f346e575116f558d7d99e256882962 Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Thu, 6 Nov 2025 22:08:07 +0100 Subject: [PATCH] formatting fixes --- tests/unit/test_database.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index 9008040..51b199c 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -26,7 +26,7 @@ def test_get_db_yields_session() -> None: def test_get_db_closes_session() -> None: """Test that get_db properly closes the session.""" from unittest.mock import patch - + init_db() db_generator = get_database() @@ -35,13 +35,13 @@ def test_get_db_closes_session() -> None: assert db.is_active # Patch the close method to verify it gets called - with patch.object(db, 'close', wraps=db.close) as mock_close: + with patch.object(db, "close", wraps=db.close) as mock_close: # Complete the generator to trigger finally block try: next(db_generator) except StopIteration: pass - + # Verify that close() was called mock_close.assert_called_once() @@ -49,7 +49,7 @@ def test_get_db_closes_session() -> None: def test_get_db_closes_on_exception() -> None: """Test that get_db closes session when used in context manager.""" from unittest.mock import patch - + init_db() # Simulate how FastAPI actually uses the dependency @@ -60,7 +60,7 @@ def test_get_db_closes_on_exception() -> None: assert db.is_active # Patch close to verify it gets called even with an exception - with patch.object(db, 'close', wraps=db.close) as mock_close: + with patch.object(db, "close", wraps=db.close) as mock_close: try: # Simulate an exception occurring during request processing raise ValueError("Simulated error during request") @@ -72,7 +72,7 @@ def test_get_db_closes_on_exception() -> None: next(db_generator) except StopIteration: pass - + # Verify close() was called despite the exception mock_close.assert_called_once() except Exception: @@ -82,6 +82,7 @@ def test_get_db_closes_on_exception() -> None: # Verify db was created assert db is not None + # def test_init_db_creates_directory(tmp_path: Path) -> None: # """Test that init_db creates the data directory.""" # import os