fix warnings
This commit is contained in:
parent
49796a3b41
commit
666f661992
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" ?>
|
||||
<coverage version="7.13.0" timestamp="1766645335309" 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="1766645611374" 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>
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ from pydantic import BaseModel, ValidationError
|
|||
from app.interfaces.base import TgBackendInterface
|
||||
|
||||
|
||||
class TestModel(BaseModel):
|
||||
"""Test Pydantic model for testing."""
|
||||
class SampleModel(BaseModel):
|
||||
"""Sample Pydantic model for testing serialization/deserialization."""
|
||||
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 = TestModel(name="test", value=42)
|
||||
model = SampleModel(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, TestModel)
|
||||
result = interface._deserialize_response(data, SampleModel)
|
||||
|
||||
assert isinstance(result, TestModel)
|
||||
assert isinstance(result, SampleModel)
|
||||
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, TestModel)
|
||||
interface._deserialize_response(data, SampleModel)
|
||||
|
||||
@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, TestModel)
|
||||
result = await interface._handle_response(mock_response, SampleModel)
|
||||
|
||||
assert isinstance(result, TestModel)
|
||||
assert isinstance(result, SampleModel)
|
||||
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=TestModel)
|
||||
result = await interface.get("/users", params={"id": 123}, response_model=SampleModel)
|
||||
|
||||
assert isinstance(result, TestModel)
|
||||
assert isinstance(result, SampleModel)
|
||||
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 = TestModel(name="new", value=50)
|
||||
body = SampleModel(name="new", value=50)
|
||||
|
||||
result = await interface.post("/users", body=body, response_model=TestModel)
|
||||
result = await interface.post("/users", body=body, response_model=SampleModel)
|
||||
|
||||
assert isinstance(result, TestModel)
|
||||
assert isinstance(result, SampleModel)
|
||||
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 = TestModel(name="updated", value=75)
|
||||
body = SampleModel(name="updated", value=75)
|
||||
|
||||
result = await interface.put("/users/1", body=body, response_model=TestModel)
|
||||
result = await interface.put("/users/1", body=body, response_model=SampleModel)
|
||||
|
||||
assert isinstance(result, TestModel)
|
||||
assert isinstance(result, SampleModel)
|
||||
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 = TestModel(name="test", value=1)
|
||||
body = SampleModel(name="test", value=1)
|
||||
|
||||
with pytest.raises(httpx.HTTPStatusError):
|
||||
await interface.post("/users", body=body)
|
||||
|
|
|
|||
Loading…
Reference in New Issue