2016-04-19 13:51:16 +01:00
|
|
|
import pytest
|
2017-11-14 17:25:32 +00:00
|
|
|
from bs4 import BeautifulSoup
|
2016-04-26 10:32:26 +01:00
|
|
|
from flask import url_for
|
2016-01-22 17:24:14 +00:00
|
|
|
|
|
|
|
|
|
2017-11-14 17:25:32 +00:00
|
|
|
def test_non_logged_in_user_can_see_homepage(
|
|
|
|
|
client,
|
|
|
|
|
):
|
|
|
|
|
response = client.get(url_for('main.index'))
|
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
|
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
|
|
|
|
|
|
|
|
|
assert page.select_one('meta[name=description]')['content'].startswith(
|
2017-11-15 13:28:35 +00:00
|
|
|
'GOV.UK Notify lets you send emails and text messages'
|
2017-11-14 17:25:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2017-02-03 10:42:01 +00:00
|
|
|
def test_logged_in_user_redirects_to_choose_service(
|
2017-02-03 12:07:21 +00:00
|
|
|
logged_in_client,
|
2017-02-03 10:42:01 +00:00
|
|
|
api_user_active,
|
|
|
|
|
mock_get_user,
|
|
|
|
|
mock_get_user_by_email,
|
|
|
|
|
mock_login,
|
|
|
|
|
):
|
2017-02-03 12:07:21 +00:00
|
|
|
response = logged_in_client.get(url_for('main.index'))
|
|
|
|
|
assert response.status_code == 302
|
2016-01-22 17:24:14 +00:00
|
|
|
|
2017-02-03 12:07:21 +00:00
|
|
|
response = logged_in_client.get(url_for('main.sign_in', follow_redirects=True))
|
|
|
|
|
assert response.location == url_for('main.choose_service', _external=True)
|
2016-09-07 10:49:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('view', [
|
2017-10-05 14:53:15 +01:00
|
|
|
'cookies', 'using_notify', 'pricing', 'terms', 'integration_testing', 'roadmap',
|
2017-11-28 11:56:30 +00:00
|
|
|
'features', 'callbacks', 'documentation', 'security'
|
2016-09-07 10:49:57 +01:00
|
|
|
])
|
2017-02-03 12:07:21 +00:00
|
|
|
def test_static_pages(
|
2017-12-01 09:46:46 +00:00
|
|
|
client_request,
|
2017-02-03 12:07:21 +00:00
|
|
|
view,
|
|
|
|
|
):
|
2017-12-01 09:46:46 +00:00
|
|
|
page = client_request.get('main.{}'.format(view))
|
2017-11-14 17:25:32 +00:00
|
|
|
assert not page.select_one('meta[name=description]')
|
|
|
|
|
|
2017-08-30 15:22:26 +01:00
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('view, expected_anchor', [
|
|
|
|
|
('delivery_and_failure', 'messagedeliveryandfailure'),
|
|
|
|
|
('trial_mode', 'trial-mode'),
|
|
|
|
|
])
|
2017-11-28 11:56:30 +00:00
|
|
|
def test_old_static_pages_redirect_to_using_notify_with_anchor(
|
2017-08-30 15:22:26 +01:00
|
|
|
client,
|
|
|
|
|
view,
|
|
|
|
|
expected_anchor,
|
|
|
|
|
):
|
|
|
|
|
response = client.get(url_for('main.{}'.format(view)))
|
|
|
|
|
assert response.status_code == 301
|
|
|
|
|
assert response.location == url_for(
|
|
|
|
|
'main.using_notify',
|
|
|
|
|
_anchor=expected_anchor,
|
|
|
|
|
_external=True
|
|
|
|
|
)
|
2017-11-28 11:56:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('view, expected_view', [
|
|
|
|
|
('information_risk_management', 'security'),
|
|
|
|
|
('old_integration_testing', 'integration_testing'),
|
|
|
|
|
('old_roadmap', 'roadmap'),
|
2017-11-28 12:00:12 +00:00
|
|
|
('information_risk_management', 'security'),
|
|
|
|
|
('old_terms', 'terms'),
|
|
|
|
|
('information_security', 'using_notify'),
|
|
|
|
|
('old_using_notify', 'using_notify'),
|
2017-11-28 11:56:30 +00:00
|
|
|
])
|
|
|
|
|
def test_old_static_pages_redirect(
|
|
|
|
|
client,
|
|
|
|
|
view,
|
|
|
|
|
expected_view
|
|
|
|
|
):
|
|
|
|
|
response = client.get(url_for('main.{}'.format(view)))
|
|
|
|
|
assert response.status_code == 301
|
|
|
|
|
assert response.location == url_for(
|
|
|
|
|
'main.{}'.format(expected_view),
|
|
|
|
|
_external=True
|
|
|
|
|
)
|