Skip to content

Commit ffff890

Browse files
committed
test(jira): add unit test informative error
1 parent b617f0c commit ffff890

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/unit/servers/test_jira_server.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,32 @@ async def test_get_issue(jira_client, mock_jira_fetcher):
427427
update_history=True,
428428
)
429429

430+
@pytest.mark.anyio
431+
async def test_get_issue_invalid_key(jira_client, mock_jira_fetcher):
432+
"""Test that get_issue fails when a key does not exist and provides an informative error."""
433+
mock_jira_fetcher.get_issue.side_effect = ValueError(
434+
"Issue Does Not Exist"
435+
)
436+
437+
with pytest.raises(ToolError) as excinfo:
438+
await jira_client.call_tool(
439+
"jira_get_issue",
440+
{
441+
"issue_key": "FAIL-123",
442+
"fields": "summary,description,status",
443+
},
444+
)
445+
446+
mock_jira_fetcher.get_issue.assert_called_once_with(
447+
issue_key="FAIL-123",
448+
fields=["summary", "description", "status"],
449+
expand=None,
450+
comment_limit=10,
451+
properties=None,
452+
update_history=True,
453+
)
454+
455+
assert "Error calling tool 'get_issue': Issue Does Not Exist" in str(excinfo.value)
430456

431457
@pytest.mark.anyio
432458
async def test_search(jira_client, mock_jira_fetcher):

0 commit comments

Comments
 (0)