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
33 changes: 33 additions & 0 deletions tests/unit/models/responses/test_authorized_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Unit tests for AuthorizedResponse model."""

import pytest

from pydantic import ValidationError

from models.responses import AuthorizedResponse


class TestAuthorizedResponse:
"""Test cases for the AuthorizedResponse model."""

def test_constructor(self) -> None:
"""Test the AuthorizedResponse constructor."""
ar = AuthorizedResponse(
user_id="123e4567-e89b-12d3-a456-426614174000",
username="testuser",
)
assert ar.user_id == "123e4567-e89b-12d3-a456-426614174000"
assert ar.username == "testuser"

def test_constructor_fields_required(self) -> None:
"""Test the AuthorizedResponse constructor."""

with pytest.raises(ValidationError):
# missing user_id parameter
_ = AuthorizedResponse(username="testuser") # pyright: ignore

with pytest.raises(ValidationError):
# missing username parameter
_ = AuthorizedResponse(
user_id="123e4567-e89b-12d3-a456-426614174000"
) # pyright: ignore
22 changes: 22 additions & 0 deletions tests/unit/models/responses/test_query_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Unit tests for QueryResponse model."""

from models.responses import QueryResponse


class TestQueryResponse:
"""Test cases for the QueryResponse model."""

def test_constructor(self) -> None:
"""Test the QueryResponse constructor."""
qr = QueryResponse(
conversation_id="123e4567-e89b-12d3-a456-426614174000",
response="LLM answer",
)
assert qr.conversation_id == "123e4567-e89b-12d3-a456-426614174000"
assert qr.response == "LLM answer"

def test_optional_conversation_id(self) -> None:
"""Test the QueryResponse with default conversation ID."""
qr = QueryResponse(response="LLM answer")
assert qr.conversation_id is None
assert qr.response == "LLM answer"
19 changes: 19 additions & 0 deletions tests/unit/models/responses/test_status_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Unit tests for StatusResponse model."""

from models.responses import StatusResponse


class TestStatusResponse:
"""Test cases for the StatusResponse model."""

def test_constructor_feedback_enabled(self) -> None:
"""Test the StatusResponse constructor."""
sr = StatusResponse(functionality="feedback", status={"enabled": True})
assert sr.functionality == "feedback"
assert sr.status == {"enabled": True}

def test_constructor_feedback_disabled(self) -> None:
"""Test the StatusResponse constructor."""
sr = StatusResponse(functionality="feedback", status={"enabled": False})
assert sr.functionality == "feedback"
assert sr.status == {"enabled": False}
23 changes: 23 additions & 0 deletions tests/unit/models/responses/test_unauthorized_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Unit tests for UnauthorizedResponse model."""

import pytest

from pydantic import ValidationError

from models.responses import UnauthorizedResponse


class TestUnauthorizedResponse:
"""Test cases for the UnauthorizedResponse model."""

def test_constructor(self) -> None:
"""Test the UnauthorizedResponse constructor."""
ur = UnauthorizedResponse(
detail="Missing or invalid credentials provided by client"
)
assert ur.detail == "Missing or invalid credentials provided by client"

def test_constructor_fields_required(self) -> None:
"""Test the UnauthorizedResponse constructor."""
with pytest.raises(ValidationError):
_ = UnauthorizedResponse() # pyright: ignore
86 changes: 0 additions & 86 deletions tests/unit/models/test_responses.py

This file was deleted.