-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for list threads and also a helper to create threads
- Loading branch information
1 parent
b2266a0
commit df723f0
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.contrib.auth.models import User | ||
|
||
from django_ai_assistant.models import Message, Thread | ||
|
||
|
||
def create_thread( | ||
name: str | None = None, user: User | None = None, message: str | None = None | ||
) -> Thread: | ||
name = name or "Test Thread" | ||
user = user or User.objects.create_user(username="test_user") | ||
message = message or "Test Message" | ||
|
||
thread = Thread.objects.create(name=name, created_by=user) | ||
|
||
Message.objects.create(message={"content": message}, thread=thread) | ||
|
||
thread.refresh_from_db() | ||
|
||
return thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters