Files
notifications-admin/tests/app/main/views/test_sign_out.py
Chris Hill-Scott 929dc45224 Normalize whitespace in test arguments
We have a bunch of different styles of handling when function
definitions span multiple lines, which they almost always do with tests.

Here’s why an argument per line, single indent is best:
- cleaner diffs when you change the name of a method (one line change
  instead of multiple lines)
- works better on narrow screens, eg Github’s diff view, or with two
  terminals side by side on a laptop screen
- works with any editor’s indenting shortcuts, no need for an IDE

Also, trailing comma in the list of arguments is good because adding a
new argument to a method becomes a one line, not two line diff.
2017-02-06 10:44:37 +00:00

44 lines
1.4 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.index', _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_jobs,
mock_has_permissions,
mock_get_template_statistics,
mock_get_detailed_service,
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.index', _external=True)
with client.session_transaction() as session:
assert session.get('user_id') is None