Skip to content

Commit

Permalink
Fix method rename made by mistake in the commit b04abb4
Browse files Browse the repository at this point in the history
  • Loading branch information
pamella committed Jun 20, 2024
1 parent e738808 commit e8aab32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions django_ai_assistant/helpers/use_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)


def get_cls(
def get_assistant_cls(
assistant_id: str,
user: Any,
request: HttpRequest | None = None,
Expand All @@ -43,7 +43,7 @@ def get_single_assistant_info(
user: Any,
request: HttpRequest | None = None,
):
assistant_cls = get_cls(assistant_id, user, request)
assistant_cls = get_assistant_cls(assistant_id, user, request)

return {
"id": assistant_id,
Expand All @@ -56,7 +56,7 @@ def get_assistants_info(
request: HttpRequest | None = None,
):
return [
get_cls(assistant_id=assistant_id, user=user, request=request)
get_assistant_cls(assistant_id=assistant_id, user=user, request=request)
for assistant_id in AIAssistant.get_cls_registry().keys()
]

Expand All @@ -68,7 +68,7 @@ def create_message(
content: Any,
request: HttpRequest | None = None,
):
assistant_cls = get_cls(assistant_id, user, request)
assistant_cls = get_assistant_cls(assistant_id, user, request)

if not can_create_message(thread=thread, user=user, request=request):
raise AIUserNotAllowedError("User is not allowed to create messages in this thread")
Expand Down
12 changes: 6 additions & 6 deletions tests/test_use_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,29 @@ def use_fake_permissions(settings):
# Assistant tests


def test_get_cls_returns_assistant_cls():
def test_get_assistant_cls_returns_assistant_cls():
assistant_id = "temperature_assistant"
user = User()

assistant_cls = use_cases.get_cls(assistant_id, user)
assistant_cls = use_cases.get_assistant_cls(assistant_id, user)

assert assistant_cls.id == assistant_id


def test_get_cls_raises_error_when_assistant_not_defined():
def test_get_assistant_cls_raises_error_when_assistant_not_defined():
assistant_id = "not_defined"
user = User()

with pytest.raises(AIAssistantNotDefinedError):
use_cases.get_cls(assistant_id, user)
use_cases.get_assistant_cls(assistant_id, user)


def test_get_cls_raises_error_when_user_not_allowed(use_fake_permissions):
def test_get_assistant_cls_raises_error_when_user_not_allowed(use_fake_permissions):
assistant_id = "temperature_assistant"
user = User()

with pytest.raises(AIUserNotAllowedError):
use_cases.get_cls(assistant_id, user)
use_cases.get_assistant_cls(assistant_id, user)


def test_get_single_assistant_info_returns_info():
Expand Down

0 comments on commit e8aab32

Please sign in to comment.