From 8e5d11c70e4f5af6fbbbac5af6c5ba239cc68ca5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 22 Jan 2020 13:47:23 +0000 Subject: [PATCH] Add a route to serve guidance pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rather than hard coding the page titles, let’s just accept anythin that’s a real template in the guidance folder – will make it easier for Karl to edit and create pages. --- app/main/views/index.py | 12 ++++++++++++ tests/app/main/views/test_index.py | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/app/main/views/index.py b/app/main/views/index.py index a910963e6..1ee5db928 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -7,6 +7,7 @@ from flask import ( url_for, ) from flask_login import current_user +from jinja2.exceptions import TemplateNotFound from notifications_utils.international_billing_rates import ( INTERNATIONAL_BILLING_RATES, ) @@ -325,6 +326,17 @@ def trial_mode_new(): ) +@main.route('/guidance') +@main.route('/guidance/') +def guidance(slug='index'): + try: + return render_template( + 'views/guidance/{}.html'.format(slug) + ) + except TemplateNotFound: + abort(404) + + # --- Redirects --- # @main.route('/roadmap', endpoint='old_roadmap') diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index 38c12b34d..41b917113 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -277,3 +277,23 @@ def test_letter_spec_redirect_with_non_logged_in_user(client_request): '/documentation/images/notify-pdf-letter-spec-v2.4.pdf' ), ) + + +def test_guidance_index(client_request): + client_request.get('main.guidance') + + +@pytest.mark.parametrize('slug', ( + 'branding-and-customisation', + 'create-and-send-messages', + 'edit-and-format-messages', + 'index', + 'send-files-by-email', + 'upload-a-letter', +)) +def test_guidance_pages(client_request, slug): + client_request.get('main.guidance', slug=slug) + + +def test_guidance_404s_for_page_that_doesnt_exist(client_request): + client_request.get('main.guidance', slug='foo', _expected_status=404)