Skip to content

Commit 79cf28a

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

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
@@ -428,6 +428,32 @@ async def test_get_issue(jira_client, mock_jira_fetcher):
428428
)
429429

430430

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

0 commit comments

Comments
 (0)