refactor: improve code formatting and readability across multiple files

This commit is contained in:
Abhimanyu Saharan
2026-02-08 00:29:14 +05:30
parent 1dfff39140
commit 527cc13c63
7 changed files with 54 additions and 30 deletions

View File

@@ -3,10 +3,14 @@ from __future__ import annotations
from fastapi import FastAPI, HTTPException
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from starlette.requests import Request
from app.core.error_handling import REQUEST_ID_HEADER, _error_payload, _get_request_id, install_error_handling
from app.core.error_handling import (
REQUEST_ID_HEADER,
_error_payload,
_get_request_id,
install_error_handling,
)
def test_request_validation_error_includes_request_id():

View File

@@ -46,7 +46,9 @@ async def test_request_id_middleware_ignores_blank_client_header_and_generates_o
assert isinstance(captured_request_id, str) and captured_request_id
# Header should reflect the generated id, not the blank one.
values = [v for k, v in response_headers if k.lower() == REQUEST_ID_HEADER.lower().encode("latin-1")]
values = [
v for k, v in response_headers if k.lower() == REQUEST_ID_HEADER.lower().encode("latin-1")
]
assert values == [captured_request_id.encode("latin-1")]
@@ -81,5 +83,7 @@ async def test_request_id_middleware_does_not_duplicate_existing_header() -> Non
assert start_headers is not None
# Ensure the middleware did not append a second copy.
values = [v for k, v in start_headers if k.lower() == REQUEST_ID_HEADER.lower().encode("latin-1")]
values = [
v for k, v in start_headers if k.lower() == REQUEST_ID_HEADER.lower().encode("latin-1")
]
assert values == [b"already"]