fix: Address code review feedback - datetime, event_loop, and readability
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ class SecurityHeadersMiddleware(BaseHTTPMiddleware):
|
||||
|
||||
# Strict Transport Security (HTTPS only)
|
||||
# Note: Only enable in production with HTTPS
|
||||
if not request.url.hostname in ["localhost", "127.0.0.1"]:
|
||||
if request.url.hostname not in ["localhost", "127.0.0.1"]:
|
||||
response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains"
|
||||
|
||||
# Content Security Policy (adjust based on frontend needs)
|
||||
|
||||
@@ -18,12 +18,8 @@ from app.core.security import get_password_hash, create_access_token
|
||||
TEST_DATABASE_URL = settings.DATABASE_URL.replace("/pop3_forwarder", "/pop3_forwarder_test")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def event_loop() -> Generator:
|
||||
"""Create event loop for async tests"""
|
||||
loop = asyncio.get_event_loop_policy().new_event_loop()
|
||||
yield loop
|
||||
loop.close()
|
||||
# Note: event_loop fixture removed - pytest-asyncio provides this automatically
|
||||
# when asyncio_mode = auto is set in pytest.ini
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
|
||||
+1
-1
@@ -292,7 +292,7 @@ class ErrorResponse(BaseModel):
|
||||
code: str # e.g., "MAIL_100"
|
||||
message: str # Human-readable message
|
||||
details: dict = {} # Additional context
|
||||
timestamp: datetime = Field(default_factory=datetime.utcnow)
|
||||
timestamp: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
||||
request_id: str = "" # For tracing
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user