Skip to content

Commit 73d15d6

Browse files
MaxNumeriquegithub-actions[bot]
authored andcommitted
Apply prepare changes
1 parent 9af0a58 commit 73d15d6

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/opengeodeweb_microservice/database/session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55

66
_database_connection = DatabaseConnection()
77

8+
89
def init_database(app: Flask, database_filename: str = "project.db") -> SQLAlchemy:
910
global _database_connection
1011
_database_connection.database_filename = database_filename
1112
return _database_connection.init_app(app)
1213

14+
1315
def get_session() -> Optional[SQLAlchemy]:
1416
return _database_connection.get_database()
1517

18+
1619
def get_database_connection() -> DatabaseConnection:
1720
return _database_connection

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def app():
2323
def _cleanup_database_connections():
2424
try:
2525
session = get_session()
26-
if session and hasattr(session, 'session'):
26+
if session and hasattr(session, "session"):
2727
session.session.close()
28-
if session and hasattr(session, 'engine'):
28+
if session and hasattr(session, "engine"):
2929
session.engine.dispose()
3030
except Exception:
3131
pass

tests/test_database.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
from src.opengeodeweb_microservice.database.session import get_session
33
from src.opengeodeweb_microservice.microservice.data import Data
44

5+
56
def test_database_session_available(app_context):
67
session = get_session()
78
assert session is not None
89
assert session.session is not None
910

11+
1012
def test_data_crud_operations(app_context, clean_database):
1113
data = Data.create(
1214
geode_object="test_object",
1315
input_file="test.txt",
14-
additional_files=["file1.txt", "file2.txt"]
16+
additional_files=["file1.txt", "file2.txt"],
1517
)
1618
assert data.id is not None
1719
assert data.geode_object == "test_object"
@@ -23,4 +25,4 @@ def test_data_crud_operations(app_context, clean_database):
2325
assert retrieved.geode_object == "test_object"
2426
assert retrieved.additional_files == ["file1.txt", "file2.txt"]
2527
non_existent = Data.get("fake_id")
26-
assert non_existent is None
28+
assert non_existent is None

0 commit comments

Comments
 (0)