Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/unit/app/endpoints/test_query_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,18 @@ async def test_query_endpoint_handler_v2_api_connection_error(
mocker.patch("app.endpoints.query_v2.configuration", mock_config)

def _raise(*_args: Any, **_kwargs: Any) -> Exception:
"""Raises a custom APIConnectionError exception.

Args:
*_args: Variable length argument list.
**_kwargs: Arbitrary keyword arguments.

Returns:
None

Raises:
APIConnectionError: Always raises this exception with a Request object.
"""
request = Request(scope={"type": "http"})
raise APIConnectionError(request=request) # type: ignore

Expand Down
11 changes: 11 additions & 0 deletions tests/unit/app/endpoints/test_rags.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ class RagInfo:
"""RagInfo mock."""

def __init__(self) -> None:
"""This function initializes an instance with predefined attributes.

Attributes:
id (str): Identifier for the instance, set to "xyzzy".
name (str): Name of the instance, set to "rag_name".
created_at (int): Creation timestamp, set to 123456.
last_active_at (int): Last active timestamp, set to 1234567.
expires_at (int): Expiry timestamp, set to 12345678.
object (str): Type of object, set to "faiss".
status (str): Status of the instance, set to "completed".
usage_bytes (int): Usage in bytes, set to 100."""
self.id = "xyzzy"
self.name = "rag_name"
self.created_at = 123456
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/authorization/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ async def test_decorator_success(

@authorize(Action.QUERY)
async def mock_endpoint(**_: Any) -> str:
"""An asynchronous function that mocks an endpoint.

Args:
**_: Any additional keyword arguments are ignored.

Returns:
A string indicating the mock operation was successful."""
return "success"

mocker.patch(
Expand All @@ -292,6 +299,13 @@ async def test_decorator_failure(

@authorize(Action.ADMIN)
async def mock_endpoint(**_: Any) -> str:
"""An asynchronous function that simulates an endpoint.

Args:
**_: Arbitrary keyword arguments.

Returns:
A string indicating the success of the operation."""
return "success"

mocker.patch(
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/utils/test_llama_stack_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ async def test_check_llama_stack_version_too_small_version(


async def _check_version_must_fail(mock_client: Any, bigger_version: Version) -> None:
"""Check if the Llama Stack version is supported and must fail if not.

Args:
mock_client: A mock client used for testing.
bigger_version: A version object representing a version higher than the supported version.

Raises:
InvalidLlamaStackVersionException: If the Llama Stack version is greater than the
maximal supported version.
"""
mock_client.inspect.version.return_value = VersionInfo(version=str(bigger_version))

expected_exception_msg = (
Expand Down
Loading