Skip to content

Commit

Permalink
tests: check error handling works for "rc"
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Feb 15, 2024
1 parent d417792 commit 0ab0e54
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/ai_horde_api/test_ai_horde_api_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Unit tests for AI-Horde API models."""
from uuid import UUID

import pytest

from horde_sdk.ai_horde_api.apimodels._find_user import (
ContributionsDetails,
FindUserRequest,
Expand Down Expand Up @@ -418,3 +420,25 @@ def test_ImageGenerateJobPopResponse() -> None:
),
skipped=ImageGenerateJobPopSkippedStatus(),
)


def test_error_response() -> None:
"""Test that an error response can be parsed correctly."""
from horde_sdk.ai_horde_api.ai_horde_clients import (
AIHordeAPIManualClient,
)
from horde_sdk.generic_api.apimodels import RequestErrorResponse

client = AIHordeAPIManualClient()

api_request = FindUserRequest(apikey="1234567890123456789012")

api_response = client.submit_request(
api_request,
api_request.get_default_success_response_type(),
)

if isinstance(api_response, RequestErrorResponse):
assert not api_response.message.startswith("The response type doesn't match expected one!")
else:
pytest.fail(f"API Response was not an error: {api_response}")

0 comments on commit 0ab0e54

Please sign in to comment.