aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/resources/tests
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-09-10 17:37:25 +0100
committerMatthew Lemon <y@yulqen.org>2024-09-10 17:37:25 +0100
commitb17cb510c32e22c59e0140c2f2d90cf6ccbed361 (patch)
treed69e688432e6063f7390fcf25e95d0919bac1792 /pyblackbird_cc/resources/tests
parent7550f31f604fa45f9030a32b9b8fbc2d0739bed7 (diff)
All tests pass and sign-up page is editable
Diffstat (limited to '')
-rw-r--r--pyblackbird_cc/resources/tests/test_file_processing.py10
-rw-r--r--pyblackbird_cc/resources/tests/test_views.py18
2 files changed, 19 insertions, 9 deletions
diff --git a/pyblackbird_cc/resources/tests/test_file_processing.py b/pyblackbird_cc/resources/tests/test_file_processing.py
index e4ac781..7b95a9d 100644
--- a/pyblackbird_cc/resources/tests/test_file_processing.py
+++ b/pyblackbird_cc/resources/tests/test_file_processing.py
@@ -1,3 +1,6 @@
+from pathlib import Path
+
+from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.core.files.uploadedfile import SimpleUploadedFile
@@ -5,9 +8,8 @@ from django.core.files.uploadedfile import TemporaryUploadedFile
from django.test import TestCase
from django.urls import reverse
-from ..utils import _get_pdf_collection_type
-
from .. import services
+from ..utils import _get_pdf_collection_type
def test_detect_snapshotted_pdf_collection():
@@ -25,7 +27,9 @@ def test_detect_snapshotted_pdf_collection():
class PDFFileUploadTestCase(TestCase):
def setUp(self):
self.url = reverse("resources:create_resource")
- self.test_file_path = "resources/tests/testdata/test_small_file.pdf"
+ self.test_file_path = Path(
+ settings.BASE_DIR / "pyblackbird_cc" / "resources/tests/testdata/test_small_file.pdf"
+ )
# Create a test user
self.email = "testuser@example.com"
diff --git a/pyblackbird_cc/resources/tests/test_views.py b/pyblackbird_cc/resources/tests/test_views.py
index e5025a5..e85dd9f 100644
--- a/pyblackbird_cc/resources/tests/test_views.py
+++ b/pyblackbird_cc/resources/tests/test_views.py
@@ -1,6 +1,8 @@
import unittest
+from pathlib import Path
import pytest
+from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
@@ -32,21 +34,25 @@ def test_create_resource_view(client):
@pytest.mark.django_db
def test_create_resource_has_form(client):
User = get_user_model()
- user = User.objects.create_user(email='testuser@example.com', password='12345')
- client.login(email='testuser@example.com', password='12345')
+ user = User.objects.create_user(email="testuser@example.com", password="12345")
+ client.login(email="testuser@example.com", password="12345")
url = reverse("resources:create_resource")
response = client.get(url)
assert response.status_code == 200
- assert 'form' in response.context
- assert isinstance(response.context['form'], ResourceCreateForm)
+ assert "form" in response.context
+ assert isinstance(response.context["form"], ResourceCreateForm)
class PDFFileUploadTestCase(TestCase):
def setUp(self):
self.url = reverse("resources:create_resource")
- self.two_page_pdf = "resources/tests/testdata/two_page.pdf"
- self.seven_page_pdf = "resources/tests/testdata/seven_page.pdf"
+ self.two_page_pdf = Path(
+ settings.BASE_DIR / "pyblackbird_cc" / "resources/tests/testdata/two_page.pdf"
+ )
+ self.seven_page_pdf = Path(
+ settings.BASE_DIR / "pyblackbird_cc" / "resources/tests/testdata/seven_page.pdf"
+ )
# Create a test user
self.email = "testuser@example.com"