Files
notifications-admin/tests/app/main/views/test_sign_out.py

38 lines
1.4 KiB
Python
Raw Normal View History

2016-01-06 16:40:38 +00:00
from datetime import datetime
from flask import url_for
from app.main.dao import users_dao
from app.models import User
2016-01-15 15:15:35 +00:00
def test_render_sign_out_redirects_to_sign_in(app_):
with app_.test_request_context():
response = app_.test_client().get(
2016-01-06 16:40:38 +00:00
url_for('main.sign_out'))
assert response.status_code == 302
assert response.location == url_for(
2016-01-06 17:17:02 +00:00
'main.sign_in', _external=True, next=url_for('main.sign_out'))
2016-01-06 16:40:38 +00:00
2016-01-15 15:15:35 +00:00
def test_sign_out_user(app_,
db_,
db_session,
mock_send_sms,
mock_send_email,
mock_get_service,
mock_api_user,
2016-01-21 11:33:53 +00:00
mock_user_loader,
mock_user_dao_get_by_email):
2016-01-15 15:15:35 +00:00
with app_.test_request_context():
2016-01-06 16:40:38 +00:00
email = 'valid@example.gov.uk'
password = 'val1dPassw0rd!'
2016-01-15 15:15:35 +00:00
with app_.test_client() as client:
client.login(mock_api_user)
2016-01-06 16:40:38 +00:00
# Check we are logged in
response = client.get(
url_for('main.service_dashboard', service_id="123"))
2016-01-06 16:40:38 +00:00
assert response.status_code == 200
response = client.get(url_for('main.sign_out'))
assert response.status_code == 302
assert response.location == url_for(
'main.index', _external=True)