diff options
Diffstat (limited to 'pyblackbird_cc/resources/tests/test_views.py')
-rw-r--r-- | pyblackbird_cc/resources/tests/test_views.py | 28 |
1 files changed, 17 insertions, 11 deletions
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" |