Coverage for src/cstlcore/constellations/dependencies.py: 90%
10 statements
« prev ^ index » next coverage.py v7.9.1, created at 2026-02-19 12:46 +0000
« prev ^ index » next coverage.py v7.9.1, created at 2026-02-19 12:46 +0000
1import uuid
3from fastapi import Depends, HTTPException
4from sqlmodel import Session
6from cstlcore.constellations.models import Constellation
7from cstlcore.database.dependencies import get_session
10def get_existing_constellation(
11 constellation_id: uuid.UUID,
12 session: Session = Depends(get_session),
13) -> Constellation:
14 """
15 Dependency to get an existing constellation by its ID.
16 Raises:
17 HTTPException: If the constellation does not exist.
18 Args:
19 constellation_id (uuid.UUID): The ID of the constellation to retrieve.
20 """
21 constellation = session.get(Constellation, constellation_id)
22 if not constellation:
23 raise HTTPException(
24 status_code=404,
25 detail="Constellation not found",
26 )
27 return constellation