diff --git a/coverage.xml b/coverage.xml index ca804bb..f5a5b04 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/unit/test_base_interface.py b/tests/unit/test_base_interface.py index 815fcd1..7c319f8 100644 --- a/tests/unit/test_base_interface.py +++ b/tests/unit/test_base_interface.py @@ -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)