fixes
This commit is contained in:
parent
666f661992
commit
da2a67bc91
16
coverage.xml
16
coverage.xml
|
|
@ -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="1766646553893" lines-valid="617" lines-covered="599" line-rate="0.9708" 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>
|
||||
|
|
@ -339,13 +339,13 @@
|
|||
</class>
|
||||
</classes>
|
||||
</package>
|
||||
<package name="interfaces" line-rate="0.9505" branch-rate="0" complexity="0">
|
||||
<package name="interfaces" line-rate="1" branch-rate="0" complexity="0">
|
||||
<classes>
|
||||
<class name="__init__.py" filename="interfaces/__init__.py" complexity="0" line-rate="1" branch-rate="0">
|
||||
<methods/>
|
||||
<lines/>
|
||||
</class>
|
||||
<class name="base.py" filename="interfaces/base.py" complexity="0" line-rate="0.9351" branch-rate="0">
|
||||
<class name="base.py" filename="interfaces/base.py" complexity="0" line-rate="1" branch-rate="0">
|
||||
<methods/>
|
||||
<lines>
|
||||
<line number="9" hits="1"/>
|
||||
|
|
@ -415,11 +415,11 @@
|
|||
<line number="252" hits="1"/>
|
||||
<line number="253" hits="1"/>
|
||||
<line number="255" hits="1"/>
|
||||
<line number="278" hits="0"/>
|
||||
<line number="279" hits="0"/>
|
||||
<line number="280" hits="0"/>
|
||||
<line number="282" hits="0"/>
|
||||
<line number="283" hits="0"/>
|
||||
<line number="278" hits="1"/>
|
||||
<line number="279" hits="1"/>
|
||||
<line number="280" hits="1"/>
|
||||
<line number="282" hits="1"/>
|
||||
<line number="283" hits="1"/>
|
||||
<line number="285" hits="1"/>
|
||||
<line number="303" hits="1"/>
|
||||
<line number="304" hits="1"/>
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class BriefBenchAPI {
|
|||
*/
|
||||
async updateSettings(settings) {
|
||||
return await this._request('/settings', {
|
||||
method: 'PUT',
|
||||
method: 'PATCH',
|
||||
headers: this._getHeaders(),
|
||||
body: JSON.stringify({ settings })
|
||||
})
|
||||
|
|
|
|||
|
|
@ -346,11 +346,11 @@ async function saveSettingsToServer(settings) {
|
|||
function extractEnvironmentSettings(envSettings) {
|
||||
return {
|
||||
apiMode: envSettings.apiMode,
|
||||
bearerToken: envSettings.bearerToken || '',
|
||||
systemPlatform: envSettings.systemPlatform || '',
|
||||
systemPlatformUser: envSettings.systemPlatformUser || '',
|
||||
platformUserId: envSettings.platformUserId || '',
|
||||
platformId: envSettings.platformId || '',
|
||||
bearerToken: envSettings.bearerToken || null,
|
||||
systemPlatform: envSettings.systemPlatform || null,
|
||||
systemPlatformUser: envSettings.systemPlatformUser || null,
|
||||
platformUserId: envSettings.platformUserId || null,
|
||||
platformId: envSettings.platformId || null,
|
||||
withClassify: envSettings.withClassify || false,
|
||||
resetSessionMode: envSettings.resetSessionMode !== false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ class TestTgBackendInterface:
|
|||
mock_client = AsyncMock()
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.content = b'{"name": "updated", "value": 75}'
|
||||
mock_response.content = b'{"name": "updated", "value": 75}'
|
||||
mock_response.json.return_value = {"name": "updated", "value": 75}
|
||||
mock_response.raise_for_status = MagicMock()
|
||||
mock_client.put.return_value = mock_response
|
||||
|
|
@ -313,6 +313,31 @@ class TestTgBackendInterface:
|
|||
call_args = mock_client.put.call_args
|
||||
assert call_args[0][0] == "http://api.example.com/users/1"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_success(self):
|
||||
"""Test successful PATCH request."""
|
||||
mock_client = AsyncMock()
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.content = b'{"name": "patched", "value": 150}'
|
||||
mock_response.json.return_value = {"name": "patched", "value": 150}
|
||||
mock_response.raise_for_status = MagicMock()
|
||||
mock_client.patch = AsyncMock(return_value=mock_response)
|
||||
|
||||
with patch('app.interfaces.base.httpx.AsyncClient', return_value=mock_client):
|
||||
interface = TgBackendInterface(api_prefix="http://api.example.com")
|
||||
body = SampleModel(name="patched", value=150)
|
||||
|
||||
result = await interface.patch("/users/1", body=body, response_model=SampleModel)
|
||||
|
||||
assert isinstance(result, SampleModel)
|
||||
assert result.name == "patched"
|
||||
assert result.value == 150
|
||||
mock_client.patch.assert_called_once()
|
||||
call_args = mock_client.patch.call_args
|
||||
assert call_args[0][0] == "http://api.example.com/users/1"
|
||||
assert call_args[1]['json'] == {"name": "patched", "value": 150}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_success(self):
|
||||
"""Test successful DELETE request."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue