Skip to content

Commit

Permalink
Test fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunns committed May 17, 2024
1 parent 15fde92 commit d643d2e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 2 additions & 3 deletions django_app/redbox_app/redbox_core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
from django.shortcuts import redirect, render
from django.urls import reverse
from django.views.decorators.http import require_http_methods
from requests.exceptions import HTTPError
from yarl import URL

from redbox_app.redbox_core.client import CoreApiClient
from redbox_app.redbox_core.models import (
ChatHistory,
Expand All @@ -22,6 +19,8 @@
ProcessingStatusEnum,
User,
)
from requests.exceptions import HTTPError
from yarl import URL

logger = logging.getLogger(__name__)

Expand Down
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.")
7 changes: 3 additions & 4 deletions django_app/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
from botocore.exceptions import ClientError
from django.conf import settings
from django.test import Client
from requests_mock import Mocker
from yarl import URL

from redbox_app.redbox_core.models import (
ChatHistory,
ChatMessage,
Expand All @@ -17,6 +14,8 @@
ProcessingStatusEnum,
User,
)
from requests_mock import Mocker
from yarl import URL

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -225,4 +224,4 @@ 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

0 comments on commit d643d2e

Please sign in to comment.