Files
notifications-admin/tests/app/main/views/test_sign_out.py
Chris Hill-Scott 00030bc254 Add usage to the dashboard
Takes the number of emails and SMS fragments sent from:
https://github.com/alphagov/notifications-api/pull/273

Using these numbers it’s possible to show:
- how much of your allowance is left
- or how much you have spent

For now the allowance and rates are hard coded.

Only for users that have manage service.
2016-05-03 11:06:12 +01:00

40 lines
1.5 KiB
Python

from flask import url_for
def test_render_sign_out_redirects_to_sign_in(app_):
with app_.test_request_context():
response = app_.test_client().get(
url_for('main.sign_out'))
assert response.status_code == 302
assert response.location == url_for(
'main.sign_in', _external=True)
def test_sign_out_user(app_,
mock_get_service,
api_user_active,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_service_templates,
mock_get_service_statistics,
mock_get_jobs,
mock_has_permissions,
mock_get_template_statistics,
mock_get_usage):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
with client.session_transaction() as session:
assert session.get('user_id') is not None
# Check we are logged in
response = client.get(
url_for('main.service_dashboard', service_id="123"))
assert response.status_code == 200
response = client.get(url_for('main.sign_out'))
assert response.status_code == 302
assert response.location == url_for(
'main.sign_in', _external=True)
with client.session_transaction() as session:
assert session.get('user_id') is None