diff options
author | Matthew Lemon <y@yulqen.org> | 2024-05-22 16:39:06 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-05-22 16:39:19 +0100 |
commit | befd3e81321e0f5989d68a6838b4a17af51b1e64 (patch) | |
tree | bf59889e587bca347dbc3807004b19c4a69ecfb6 | |
parent | ff1aa3aa113e507f870eba4c96099946f154fb22 (diff) |
wip: starting to test the featured resource view
-rw-r--r-- | pyblackbird_cc/resources/tests/conftest.py | 5 | ||||
-rw-r--r-- | pyblackbird_cc/resources/tests/test_views.py | 8 | ||||
-rw-r--r-- | pyblackbird_cc/resources/urls.py | 1 | ||||
-rw-r--r-- | pyblackbird_cc/resources/views.py | 5 | ||||
-rw-r--r-- | pyblackbird_cc/templates/resources/create_featured_resource.html | 9 |
5 files changed, 28 insertions, 0 deletions
diff --git a/pyblackbird_cc/resources/tests/conftest.py b/pyblackbird_cc/resources/tests/conftest.py index 0d1ed87..9b401ba 100644 --- a/pyblackbird_cc/resources/tests/conftest.py +++ b/pyblackbird_cc/resources/tests/conftest.py @@ -6,3 +6,8 @@ from pyblackbird_cc.resources.factories import ResourceModelFactory @pytest.fixture() def resources(): return ResourceModelFactory.create_batch(5) + + +@pytest.fixture() +def resource(): + return ResourceModelFactory() diff --git a/pyblackbird_cc/resources/tests/test_views.py b/pyblackbird_cc/resources/tests/test_views.py index e71b3a2..b961d3a 100644 --- a/pyblackbird_cc/resources/tests/test_views.py +++ b/pyblackbird_cc/resources/tests/test_views.py @@ -1,5 +1,6 @@ import unittest +import pytest from django.contrib.auth import get_user_model from django.contrib.auth.models import User from django.core.files.uploadedfile import SimpleUploadedFile @@ -13,6 +14,13 @@ from ..models import ResourceType from ..views import create_resource +@pytest.mark.django_db() +def test_create_featured_resource_view(resource, client): + url = reverse("resources:create_featured") + response = client.get(url) + assert response.status_code == 302 + + class PDFFileUploadTestCase(TestCase): def setUp(self): self.url = reverse("resources:create_resource") diff --git a/pyblackbird_cc/resources/urls.py b/pyblackbird_cc/resources/urls.py index ad5741f..01c9e2e 100644 --- a/pyblackbird_cc/resources/urls.py +++ b/pyblackbird_cc/resources/urls.py @@ -6,6 +6,7 @@ app_name = "resources" urlpatterns = [ path("", views.index, name="resource_list"), path("create/", views.create_resource, name="create_resource"), + path("featured/", views.create_featured, name="create_featured"), path("resource/<int:resource_id>", views.resource_detail, name="resource_detail"), path( "resource/update-metadata/<int:pk>", diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index bc55842..9fcb77b 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -42,6 +42,11 @@ class ResourceInfo: updated: str +@login_required +def create_featured(request): + return render(request, "resources/create_featured_resource.html") + + def _extract_metadata_from_resource(resource_obj) -> ResourceInfo | None: """ This function extracts the resource information from the model object and returns it as a diff --git a/pyblackbird_cc/templates/resources/create_featured_resource.html b/pyblackbird_cc/templates/resources/create_featured_resource.html new file mode 100644 index 0000000..7995cad --- /dev/null +++ b/pyblackbird_cc/templates/resources/create_featured_resource.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}?Add featured resource{% endblock title %} + +{% block content %} +<p>Bobbins -totalus bobinus</p> +{% endblock content %} + |