DEVX-91: refactor: add find_task_by_identifier, config fallbacks for tools
This commit is contained in:
@@ -781,6 +781,42 @@ class TestVikunjaClient:
|
||||
call_kwargs = client._session.request.call_args.kwargs
|
||||
assert call_kwargs["json"]["description"] == ""
|
||||
|
||||
def test_find_task_by_identifier_found(self) -> None:
|
||||
client = VikunjaClient("https://work.example.com", "tok")
|
||||
client._session.request = MagicMock(
|
||||
return_value=_mock_response([{"identifier": "DEVX-1"}, {"identifier": "DEVX-42", "title": "Found"}])
|
||||
)
|
||||
result = client.find_task_by_identifier(6, "DEVX-42", per_page=50)
|
||||
assert result is not None
|
||||
assert result["title"] == "Found"
|
||||
|
||||
def test_find_task_by_identifier_not_found(self) -> None:
|
||||
client = VikunjaClient("https://work.example.com", "tok")
|
||||
client._session.request = MagicMock(
|
||||
return_value=_mock_response([{"identifier": "DEVX-1"}, {"identifier": "DEVX-2"}])
|
||||
)
|
||||
result = client.find_task_by_identifier(6, "DEVX-99", per_page=50)
|
||||
assert result is None
|
||||
|
||||
def test_find_task_by_identifier_empty_project(self) -> None:
|
||||
client = VikunjaClient("https://work.example.com", "tok")
|
||||
client._session.request = MagicMock(return_value=_mock_response([]))
|
||||
result = client.find_task_by_identifier(6, "DEVX-1", per_page=50)
|
||||
assert result is None
|
||||
|
||||
def test_find_task_by_identifier_paginates(self) -> None:
|
||||
client = VikunjaClient("https://work.example.com", "tok")
|
||||
full_page = [{"identifier": f"DEVX-{i}"} for i in range(50)]
|
||||
client._session.request = MagicMock(
|
||||
side_effect=[
|
||||
_mock_response(full_page),
|
||||
_mock_response([{"identifier": "DEVX-50", "title": "Found on page 2"}]),
|
||||
]
|
||||
)
|
||||
result = client.find_task_by_identifier(6, "DEVX-50", per_page=50)
|
||||
assert result is not None
|
||||
assert result["title"] == "Found on page 2"
|
||||
|
||||
|
||||
class TestIsRetryable:
|
||||
def test_connection_error_is_retryable(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user