Compare commits

..

No commits in common. "666f66199281154d666d7a1275876e325f4096e0" and "74cdc196c64f34b54d7bf72429c975b53d3650f5" have entirely different histories.

6 changed files with 34 additions and 34 deletions

View File

@ -14,7 +14,7 @@ from app.services.rag_service import RagService
from app.dependencies import get_db_client, get_current_user
import httpx
import logging
from datetime import datetime, UTC
from datetime import datetime
import uuid
logger = logging.getLogger(__name__)
@ -93,7 +93,7 @@ async def bench_query(
return QueryResponse(
request_id=request_id,
timestamp=datetime.now(UTC).isoformat().replace('+00:00', 'Z'),
timestamp=datetime.utcnow().isoformat() + "Z",
environment=environment,
response=response_data
)
@ -181,7 +181,7 @@ async def backend_query(
return QueryResponse(
request_id=request_id,
timestamp=datetime.now(UTC).isoformat().replace('+00:00', 'Z'),
timestamp=datetime.utcnow().isoformat() + "Z",
environment=environment,
response={"answers": response_data}
)

View File

@ -10,7 +10,7 @@ import logging
import httpx
import uuid
from typing import List, Dict, Optional, Any
from datetime import datetime, UTC
from datetime import datetime
from app.config import settings
from app.models.query import QuestionRequest, RagResponseBenchList
@ -277,7 +277,7 @@ class RagService:
for idx, question in enumerate(questions, start=1):
now = datetime.now(UTC).isoformat().replace('+00:00', 'Z')
now = datetime.utcnow().isoformat() + "Z"
body = {
"question": question.body,
"user_message_id": idx,

View File

@ -1,6 +1,6 @@
"""JWT token encoding/decoding utilities."""
from datetime import datetime, timedelta, UTC
from datetime import datetime, timedelta
from typing import Optional
from jose import JWTError, jwt
@ -22,9 +22,9 @@ def create_access_token(data: dict, expires_delta: Optional[timedelta] = None) -
to_encode = data.copy()
if expires_delta:
expire = datetime.now(UTC) + expires_delta
expire = datetime.utcnow() + expires_delta
else:
expire = datetime.now(UTC) + timedelta(minutes=settings.JWT_EXPIRE_MINUTES)
expire = datetime.utcnow() + timedelta(minutes=settings.JWT_EXPIRE_MINUTES)
to_encode.update({"exp": int(expire.timestamp())})

View File

@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<coverage version="7.13.0" timestamp="1766645611374" lines-valid="617" lines-covered="594" line-rate="0.9627" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<coverage version="7.13.0" timestamp="1766645017585" lines-valid="617" lines-covered="594" line-rate="0.9627" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.13.0 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>

View File

@ -12,7 +12,7 @@ if test_env_path.exists():
import pytest
from unittest.mock import AsyncMock, MagicMock
from fastapi.testclient import TestClient
from datetime import datetime, timedelta, UTC
from datetime import datetime, timedelta
from app.main import app
from app.dependencies import get_db_client, get_current_user
@ -52,8 +52,8 @@ def test_user_response(test_user):
return UserResponse(
user_id=test_user["user_id"],
login=test_user["login"],
last_login_at=datetime.now(UTC).isoformat().replace('+00:00', 'Z'),
created_at=datetime.now(UTC).isoformat().replace('+00:00', 'Z')
last_login_at=datetime.utcnow().isoformat() + "Z",
created_at=datetime.utcnow().isoformat() + "Z"
)
@ -101,7 +101,7 @@ def test_settings():
"psi": env_settings.model_copy(),
"prod": env_settings.model_copy()
},
updated_at=datetime.now(UTC).isoformat().replace('+00:00', 'Z')
updated_at=datetime.utcnow().isoformat() + "Z"
)

View File

@ -7,8 +7,8 @@ from pydantic import BaseModel, ValidationError
from app.interfaces.base import TgBackendInterface
class SampleModel(BaseModel):
"""Sample Pydantic model for testing serialization/deserialization."""
class TestModel(BaseModel):
"""Test Pydantic model for testing."""
name: str
value: int
@ -92,7 +92,7 @@ class TestTgBackendInterface:
"""Test serializing Pydantic model to dict."""
with patch('app.interfaces.base.httpx.AsyncClient'):
interface = TgBackendInterface(api_prefix="http://api.example.com")
model = SampleModel(name="test", value=42)
model = TestModel(name="test", value=42)
result = interface._serialize_body(model)
@ -113,9 +113,9 @@ class TestTgBackendInterface:
interface = TgBackendInterface(api_prefix="http://api.example.com")
data = {"name": "test", "value": 42}
result = interface._deserialize_response(data, SampleModel)
result = interface._deserialize_response(data, TestModel)
assert isinstance(result, SampleModel)
assert isinstance(result, TestModel)
assert result.name == "test"
assert result.value == 42
@ -137,7 +137,7 @@ class TestTgBackendInterface:
data = {"name": "test"}
with pytest.raises(ValidationError):
interface._deserialize_response(data, SampleModel)
interface._deserialize_response(data, TestModel)
@pytest.mark.asyncio
async def test_handle_response_success(self):
@ -151,9 +151,9 @@ class TestTgBackendInterface:
mock_response.json.return_value = {"name": "test", "value": 42}
mock_response.raise_for_status = MagicMock()
result = await interface._handle_response(mock_response, SampleModel)
result = await interface._handle_response(mock_response, TestModel)
assert isinstance(result, SampleModel)
assert isinstance(result, TestModel)
assert result.name == "test"
mock_response.raise_for_status.assert_called_once()
@ -237,9 +237,9 @@ class TestTgBackendInterface:
with patch('app.interfaces.base.httpx.AsyncClient', return_value=mock_client):
interface = TgBackendInterface(api_prefix="http://api.example.com")
result = await interface.get("/users", params={"id": 123}, response_model=SampleModel)
result = await interface.get("/users", params={"id": 123}, response_model=TestModel)
assert isinstance(result, SampleModel)
assert isinstance(result, TestModel)
assert result.name == "test"
mock_client.get.assert_called_once()
call_args = mock_client.get.call_args
@ -259,11 +259,11 @@ class TestTgBackendInterface:
with patch('app.interfaces.base.httpx.AsyncClient', return_value=mock_client):
interface = TgBackendInterface(api_prefix="http://api.example.com")
body = SampleModel(name="new", value=50)
body = TestModel(name="new", value=50)
result = await interface.post("/users", body=body, response_model=SampleModel)
result = await interface.post("/users", body=body, response_model=TestModel)
assert isinstance(result, SampleModel)
assert isinstance(result, TestModel)
assert result.name == "created"
mock_client.post.assert_called_once()
call_args = mock_client.post.call_args
@ -303,11 +303,11 @@ class TestTgBackendInterface:
with patch('app.interfaces.base.httpx.AsyncClient', return_value=mock_client):
interface = TgBackendInterface(api_prefix="http://api.example.com")
body = SampleModel(name="updated", value=75)
body = TestModel(name="updated", value=75)
result = await interface.put("/users/1", body=body, response_model=SampleModel)
result = await interface.put("/users/1", body=body, response_model=TestModel)
assert isinstance(result, SampleModel)
assert isinstance(result, TestModel)
assert result.name == "updated"
mock_client.put.assert_called_once()
call_args = mock_client.put.call_args
@ -373,7 +373,7 @@ class TestTgBackendInterface:
with patch('app.interfaces.base.httpx.AsyncClient', return_value=mock_client):
interface = TgBackendInterface(api_prefix="http://api.example.com")
body = SampleModel(name="test", value=1)
body = TestModel(name="test", value=1)
with pytest.raises(httpx.HTTPStatusError):
await interface.post("/users", body=body)