Skip to content

Commit f155673

Browse files
committed
chore: add dependency locking step in CI workflow and improve type hinting in tests
1 parent 994ca56 commit f155673

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
uv.lock
4141
pyproject.toml
4242
43+
- name: Lock dependencies for current matrix
44+
run: uv lock
45+
4346
- name: Install dependencies
4447
run: uv sync --locked
4548

tests/tools/test_aigc_error_handling.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def test_polling_task_failed_status(self, mcp_server, mocker):
6969
)
7070

7171
# Mock polling to return FAILED status
72-
mock_get = mocker.patch(
72+
_ = mocker.patch(
7373
"modelscope_mcp_server.client.ModelScopeClient.get",
7474
new_callable=mocker.AsyncMock,
7575
return_value={
@@ -244,7 +244,7 @@ async def test_missing_output_images_in_success(self, mcp_server, mocker):
244244
return_value={"task_id": "no-images-task"},
245245
)
246246

247-
mock_get = mocker.patch(
247+
_ = mocker.patch(
248248
"modelscope_mcp_server.client.ModelScopeClient.get",
249249
new_callable=mocker.AsyncMock,
250250
return_value={
@@ -273,7 +273,7 @@ async def test_empty_output_images_array(self, mcp_server, mocker):
273273
return_value={"task_id": "empty-images-task"},
274274
)
275275

276-
mock_get = mocker.patch(
276+
_ = mocker.patch(
277277
"modelscope_mcp_server.client.ModelScopeClient.get",
278278
new_callable=mocker.AsyncMock,
279279
return_value={
@@ -341,7 +341,7 @@ async def mock_get_side_effect(url, *args, **kwargs):
341341
return responses.pop(0)
342342
return {"task_status": "PENDING"}
343343

344-
mock_get = mocker.patch(
344+
_ = mocker.patch(
345345
"modelscope_mcp_server.client.ModelScopeClient.get",
346346
new_callable=mocker.AsyncMock,
347347
side_effect=mock_get_side_effect,
@@ -363,11 +363,15 @@ async def mock_get_side_effect(url, *args, **kwargs):
363363
results = await asyncio.gather(*tasks, return_exceptions=True)
364364

365365
# Verify outcomes
366+
from typing import Any, cast
367+
366368
assert not isinstance(results[0], Exception) # First succeeded
367-
assert results[0].data.image_url == "https://example.com/image1.jpg"
369+
result0 = cast(Any, results[0])
370+
assert result0.data.image_url == "https://example.com/image1.jpg"
368371

369372
assert isinstance(results[1], Exception) # Second failed
370373
assert "Task 2 failed" in str(results[1])
371374

372375
assert not isinstance(results[2], Exception) # Third succeeded
373-
assert results[2].data.image_url == "https://example.com/image3.jpg"
376+
result2 = cast(Any, results[2])
377+
assert result2.data.image_url == "https://example.com/image3.jpg"

tests/tools/test_generate_image.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ async def test_generate_image_api_error_response(mcp_server, mocker):
141141
mocker.patch(
142142
"modelscope_mcp_server.client.ModelScopeClient.post",
143143
new_callable=mocker.AsyncMock,
144-
side_effect=httpx.HTTPStatusError("404 Client Error: Not Found", request=None, response=None),
144+
side_effect=httpx.HTTPStatusError(
145+
"404 Client Error: Not Found",
146+
request=httpx.Request("POST", "https://example.com"),
147+
response=httpx.Response(404, request=httpx.Request("POST", "https://example.com")),
148+
),
145149
)
146150

147151
async with Client(mcp_server) as client:

0 commit comments

Comments
 (0)