mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 09:29:49 -04:00
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.
44 lines
1.4 KiB
Python
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
|