fix: Update HTTP status code for unprocessable entity and improve test database setup
All checks were successful
Run Tests / test (push) Successful in 1m51s
All checks were successful
Run Tests / test (push) Successful in 1m51s
This commit is contained in:
@@ -75,7 +75,7 @@ def update_css_settings(payload: CSSSettingsPayload, db: Session = Depends(get_d
|
|||||||
]
|
]
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||||
detail=str(exc),
|
detail=str(exc),
|
||||||
) from exc
|
) from exc
|
||||||
return CSSSettingsResponse(
|
return CSSSettingsResponse(
|
||||||
|
|||||||
@@ -68,10 +68,13 @@ def setup_database() -> Generator[None, None, None]:
|
|||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def db_session() -> Generator[Session, None, None]:
|
def db_session() -> Generator[Session, None, None]:
|
||||||
|
Base.metadata.drop_all(bind=engine)
|
||||||
|
Base.metadata.create_all(bind=engine)
|
||||||
session = TestingSessionLocal()
|
session = TestingSessionLocal()
|
||||||
try:
|
try:
|
||||||
yield session
|
yield session
|
||||||
finally:
|
finally:
|
||||||
|
session.rollback()
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user