Test that static pages work w/out current_service

If you sign in, don’t choose a service then navigate to a state page
then it’s possible `current_service` won’t be set, in which case you
shouldn’t be generating URLs that need `current_service.id`.
This commit is contained in:
Chris Hill-Scott
2019-10-31 09:43:16 +00:00
parent fa72c35fce
commit 9b91132276

View File

@@ -1,3 +1,4 @@
from functools import partial
import pytest
from bs4 import BeautifulSoup
from flask import url_for
@@ -81,14 +82,23 @@ def test_static_pages(
mock_get_organisation_by_domain,
view,
):
page = client_request.get('main.{}'.format(view))
request = partial(client_request.get, 'main.{}'.format(view))
# Check the page loads when user is signed in
page = request()
assert not page.select_one('meta[name=description]')
# Check it still works when they dont have a recent service
with client_request.session_transaction() as session:
session['service_id'] = None
request()
# Check it still works when they sign out
client_request.logout()
with client_request.session_transaction() as session:
session['service_id'] = None
session['user_id'] = None
client_request.get('main.{}'.format(view))
request()
@pytest.mark.parametrize('view, expected_view', [