Skip to content

Commit 5b98806

Browse files
committed
Wrap 'murfey_db' in 'count_number_of_movies' endpoint in a 'Depends()'
1 parent d924d0c commit 5b98806

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/murfey/server/api/session_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def register_processing_success_in_ispyb(
181181

182182

183183
@router.get("/num_movies")
184-
def count_number_of_movies(db=murfey_db) -> Dict[str, int]:
184+
def count_number_of_movies(db: Session = Depends(murfey_db)) -> Dict[str, int]:
185185
res = db.exec(
186186
select(Movie.tag, func.count(Movie.murfey_id)).group_by(Movie.tag)
187187
).all()

tests/server/api/test_movies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def test_movie_count(
22-
mock_security_configuration,
22+
mock_security_configuration, # From conftest.py
2323
murfey_db_session: Session, # From conftest.py
2424
):
2525

@@ -105,6 +105,7 @@ def override_get_db():
105105
app.dependency_overrides[murfey_db] = override_get_db
106106
app.dependency_overrides[validate_instrument_token] = lambda: None
107107

108+
# Test endpoint
108109
with TestClient(app) as client:
109110
response = client.get(
110111
f"{url_path_for('session_control.router', 'count_number_of_movies')}",

0 commit comments

Comments
 (0)