Skip to content

Commit

Permalink
Merge pull request #403 from i-dot-ai/bugfix/document-unique-name-loc…
Browse files Browse the repository at this point in the history
…ally

Bugfix/document unique name locally
  • Loading branch information
252afh authored May 17, 2024
2 parents b37f2e1 + 052c7d6 commit 02e4b07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 10 additions & 2 deletions django_app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest
import pytz
from django.core.files.uploadedfile import SimpleUploadedFile, UploadedFile
from django.core.management import call_command
from redbox_app.redbox_core import client
from redbox_app.redbox_core.models import ChatHistory, ChatMessage, ChatRoleEnum, File, User
Expand Down Expand Up @@ -105,6 +106,13 @@ def chat_message(chat_history: ChatHistory, uploaded_file: File) -> ChatMessage:


@pytest.fixture
def uploaded_file(alice: User) -> File:
file = File.objects.create(user=alice, original_file_name="uploaded_file.pdf", core_file_uuid=uuid.uuid4())
def uploaded_file(alice: User, original_file: UploadedFile) -> File:
file = File.objects.create(
user=alice, original_file=original_file, original_file_name=original_file.name, core_file_uuid=uuid.uuid4()
)
return file


@pytest.fixture
def original_file() -> UploadedFile:
return SimpleUploadedFile("original_file.txt", b"Lorem Ipsum.")
5 changes: 2 additions & 3 deletions django_app/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from botocore.exceptions import ClientError
from django.conf import settings
from django.test import Client
from redbox_app.redbox_core.auth_views import get_or_create_user
from redbox_app.redbox_core.models import (
ChatHistory,
ChatMessage,
Expand All @@ -17,8 +18,6 @@
from requests_mock import Mocker
from yarl import URL

from redbox_app.redbox_core.auth_views import get_or_create_user

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -235,7 +234,7 @@ def test_view_session_with_documents(chat_message: ChatMessage, client: Client):

# Then
assert response.status_code == HTTPStatus.OK
assert b"uploaded_file.pdf" in response.content
assert b"original_file.txt" in response.content


@pytest.mark.django_db
Expand Down

0 comments on commit 02e4b07

Please sign in to comment.