@@ -223,6 +223,8 @@ async def test_create_issue_handles_api_error(issues_client, mock_client):
223223@pytest .mark .asyncio
224224async def test_get_issue_comments (issues_client , mock_client ):
225225 """Test getting comments for an issue."""
226+ from youtrack_rocket_mcp .api .schemas import IssueCommentDict
227+
226228 mock_response = [
227229 {
228230 'id' : 'comment-1' ,
@@ -241,9 +243,11 @@ async def test_get_issue_comments(issues_client, mock_client):
241243
242244 result = await issues_client .get_issue_comments ('TEST-1' )
243245
244- # Check API was called correctly
246+ # Check API was called correctly with schema
245247 expected_fields = 'id,created,text,author(id,login,name)'
246- mock_client .get .assert_called_once_with (f'issues/TEST-1/comments?fields={ expected_fields } ' )
248+ mock_client .get .assert_called_once_with (
249+ f'issues/TEST-1/comments?fields={ expected_fields } ' , schema = list [IssueCommentDict ]
250+ )
247251
248252 # Check result
249253 assert result == mock_response
@@ -253,53 +257,6 @@ async def test_get_issue_comments(issues_client, mock_client):
253257 assert result [0 ]['author' ]['login' ] == 'john.doe'
254258
255259
256- @pytest .mark .asyncio
257- async def test_get_issue_comments_nested_response (issues_client , mock_client ):
258- """Test getting comments when API returns nested structure."""
259- mock_comments = [{'id' : 'comment-1' , 'created' : 1234567890 , 'text' : 'Test comment' }]
260- mock_response = {'comments' : mock_comments }
261- mock_client .get .return_value = mock_response
262-
263- result = await issues_client .get_issue_comments ('TEST-1' )
264-
265- # Check result extracts comments from nested structure
266- assert result == mock_comments
267-
268-
269- @pytest .mark .asyncio
270- async def test_get_issue_comments_fallback_to_issue_data (issues_client , mock_client ):
271- """Test fallback to getting comments from issue data."""
272- mock_comments = [{'id' : 'comment-1' , 'created' : 1234567890 , 'text' : 'Test comment' }]
273-
274- # First call returns invalid data, second call (fallback) returns issue with comments
275- mock_client .get .side_effect = [
276- 'invalid_response' , # First call fails
277- {'comments' : mock_comments }, # Fallback call succeeds
278- ]
279-
280- result = await issues_client .get_issue_comments ('TEST-1' )
281-
282- # Check both API calls were made
283- assert mock_client .get .call_count == 2
284- expected_fields = 'id,created,text,author(id,login,name)'
285- mock_client .get .assert_any_call (f'issues/TEST-1/comments?fields={ expected_fields } ' )
286- mock_client .get .assert_any_call (f'issues/TEST-1?fields=comments({ expected_fields } )' )
287-
288- # Check result
289- assert result == mock_comments
290-
291-
292- @pytest .mark .asyncio
293- async def test_get_issue_comments_empty_response (issues_client , mock_client ):
294- """Test getting comments when no comments exist."""
295- mock_client .get .side_effect = ['invalid_response' , 'invalid_response' ]
296-
297- result = await issues_client .get_issue_comments ('TEST-1' )
298-
299- # Should return empty list when no valid response
300- assert result == []
301-
302-
303260@pytest .mark .asyncio
304261async def test_add_comment (issues_client , mock_client ):
305262 """Test adding a comment to an issue."""
0 commit comments