diff --git a/tests/unit/app/endpoints/test_query_v2.py b/tests/unit/app/endpoints/test_query_v2.py index 247a4261e..4adfca306 100644 --- a/tests/unit/app/endpoints/test_query_v2.py +++ b/tests/unit/app/endpoints/test_query_v2.py @@ -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 diff --git a/tests/unit/app/endpoints/test_rags.py b/tests/unit/app/endpoints/test_rags.py index f8f3390ca..a3630dbed 100644 --- a/tests/unit/app/endpoints/test_rags.py +++ b/tests/unit/app/endpoints/test_rags.py @@ -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 diff --git a/tests/unit/authorization/test_middleware.py b/tests/unit/authorization/test_middleware.py index 14490e022..8cd2ea97e 100644 --- a/tests/unit/authorization/test_middleware.py +++ b/tests/unit/authorization/test_middleware.py @@ -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( @@ -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( diff --git a/tests/unit/utils/test_llama_stack_version.py b/tests/unit/utils/test_llama_stack_version.py index 43790b801..22fb96fdc 100644 --- a/tests/unit/utils/test_llama_stack_version.py +++ b/tests/unit/utils/test_llama_stack_version.py @@ -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 = (