mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
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.
This commit is contained in:
@@ -4,7 +4,10 @@ from app.main.forms import TwoFactorForm
|
||||
from app import user_api_client
|
||||
|
||||
|
||||
def test_form_is_valid_returns_no_errors(app_, mock_check_verify_code):
|
||||
def test_form_is_valid_returns_no_errors(
|
||||
app_,
|
||||
mock_check_verify_code,
|
||||
):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': '12345'}) as req:
|
||||
def _check_code(code):
|
||||
@@ -14,7 +17,10 @@ def test_form_is_valid_returns_no_errors(app_, mock_check_verify_code):
|
||||
assert len(form.errors) == 0
|
||||
|
||||
|
||||
def test_returns_errors_when_code_is_too_short(app_, mock_check_verify_code):
|
||||
def test_returns_errors_when_code_is_too_short(
|
||||
app_,
|
||||
mock_check_verify_code,
|
||||
):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': '145'}) as req:
|
||||
def _check_code(code):
|
||||
@@ -25,7 +31,10 @@ def test_returns_errors_when_code_is_too_short(app_, mock_check_verify_code):
|
||||
assert set(form.errors) == set({'sms_code': ['Code must be 5 digits', 'Code does not match']})
|
||||
|
||||
|
||||
def test_returns_errors_when_code_is_missing(app_, mock_check_verify_code):
|
||||
def test_returns_errors_when_code_is_missing(
|
||||
app_,
|
||||
mock_check_verify_code,
|
||||
):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={}) as req:
|
||||
def _check_code(code):
|
||||
@@ -36,7 +45,10 @@ def test_returns_errors_when_code_is_missing(app_, mock_check_verify_code):
|
||||
assert set(form.errors) == set({'sms_code': ['Code must not be empty']})
|
||||
|
||||
|
||||
def test_returns_errors_when_code_contains_letters(app_, mock_check_verify_code):
|
||||
def test_returns_errors_when_code_contains_letters(
|
||||
app_,
|
||||
mock_check_verify_code,
|
||||
):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': 'asdfg'}) as req:
|
||||
def _check_code(code):
|
||||
@@ -47,8 +59,10 @@ def test_returns_errors_when_code_contains_letters(app_, mock_check_verify_code)
|
||||
assert set(form.errors) == set({'sms_code': ['Code must be 5 digits', 'Code does not match']})
|
||||
|
||||
|
||||
def test_should_return_errors_when_code_is_expired(app_,
|
||||
mock_check_verify_code_code_expired):
|
||||
def test_should_return_errors_when_code_is_expired(
|
||||
app_,
|
||||
mock_check_verify_code_code_expired,
|
||||
):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': '23456'}) as req:
|
||||
def _check_code(code):
|
||||
|
||||
Reference in New Issue
Block a user