diff options
Diffstat (limited to 'pyblackbird_cc/resources/tests')
-rw-r--r-- | pyblackbird_cc/resources/tests/test_file_processing.py | 10 | ||||
-rw-r--r-- | pyblackbird_cc/resources/tests/test_forms.py | 1 | ||||
-rw-r--r-- | pyblackbird_cc/resources/tests/test_views.py | 28 |
3 files changed, 24 insertions, 15 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_forms.py b/pyblackbird_cc/resources/tests/test_forms.py index 9190f55..318071d 100644 --- a/pyblackbird_cc/resources/tests/test_forms.py +++ b/pyblackbird_cc/resources/tests/test_forms.py @@ -1,5 +1,4 @@ import pytest -from django.core.exceptions import ValidationError from django.core.files.uploadedfile import SimpleUploadedFile from django.db import IntegrityError from django.test import TestCase diff --git a/pyblackbird_cc/resources/tests/test_views.py b/pyblackbird_cc/resources/tests/test_views.py index e5025a5..87b9fc0 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 @@ -8,11 +10,11 @@ from django.test import RequestFactory from django.test import TestCase from django.urls import reverse -from .. import services -from ..forms import ResourceCreateForm -from ..models import ResourceCategory -from ..models import ResourceType -from ..views import create_resource +from pyblackbird_cc.resources import services +from pyblackbird_cc.resources.forms import ResourceCreateForm +from pyblackbird_cc.resources.models import ResourceCategory +from pyblackbird_cc.resources.models import ResourceType +from pyblackbird_cc.resources.views import create_resource pytestmark = pytest.mark.django_db @@ -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" |