From 378ad72754bb55e9f6e64669a14561be9e42885f Mon Sep 17 00:00:00 2001 From: Duncan Brown Date: Thu, 29 Feb 2024 17:47:58 +0000 Subject: [PATCH] Implement hardcoded question page and test Our first end-to-end test --- .../consultations/templates/show_question.html | 1 + consultation_analyser/consultations/urls.py | 4 ++++ consultation_analyser/consultations/views.py | 7 ++++++- consultation_analyser/settings/base.py | 2 +- consultation_analyser/urls.py | 5 ++++- tests/integration/test_question_page.py | 3 +++ 6 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 consultation_analyser/consultations/templates/show_question.html create mode 100644 consultation_analyser/consultations/urls.py create mode 100644 tests/integration/test_question_page.py diff --git a/consultation_analyser/consultations/templates/show_question.html b/consultation_analyser/consultations/templates/show_question.html new file mode 100644 index 00000000..735fc822 --- /dev/null +++ b/consultation_analyser/consultations/templates/show_question.html @@ -0,0 +1 @@ +How should funding be allocated? diff --git a/consultation_analyser/consultations/urls.py b/consultation_analyser/consultations/urls.py new file mode 100644 index 00000000..4f714509 --- /dev/null +++ b/consultation_analyser/consultations/urls.py @@ -0,0 +1,4 @@ +from django.urls import path +from .views import show_question + +urlpatterns = [path("questions/how-should-funding-be-allocated", show_question)] diff --git a/consultation_analyser/consultations/views.py b/consultation_analyser/consultations/views.py index 60f00ef0..86d43467 100644 --- a/consultation_analyser/consultations/views.py +++ b/consultation_analyser/consultations/views.py @@ -1 +1,6 @@ -# Create your views here. +from django.shortcuts import render +from django.http import HttpRequest + + +def show_question(request: HttpRequest): + return render(request, "show_question.html") diff --git a/consultation_analyser/settings/base.py b/consultation_analyser/settings/base.py index 04d57431..8840b076 100644 --- a/consultation_analyser/settings/base.py +++ b/consultation_analyser/settings/base.py @@ -48,7 +48,7 @@ "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -# ROOT_URLCONF = "consultation_analyser.urls" +ROOT_URLCONF = "consultation_analyser.urls" TEMPLATES = [ { diff --git a/consultation_analyser/urls.py b/consultation_analyser/urls.py index 24e98821..a3f28205 100644 --- a/consultation_analyser/urls.py +++ b/consultation_analyser/urls.py @@ -14,4 +14,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -# from django.urls import path +from django.urls import path, include +from consultation_analyser.consultations import urls + +urlpatterns = [path("", include(urls))] diff --git a/tests/integration/test_question_page.py b/tests/integration/test_question_page.py new file mode 100644 index 00000000..b34cce87 --- /dev/null +++ b/tests/integration/test_question_page.py @@ -0,0 +1,3 @@ +def test_get_question_page(client): + response = client.get("/questions/how-should-funding-be-allocated") + assert "How should funding be allocated?" in str(response.content)