mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-06 06:31:33 -04:00
Rename "app_" fixture to "notify_admin"
This naming was introduced in 2016 without explanation [1]. I find it confusing because: - It's reminiscent of "_app", which is a Python convention indicating the variable is internal, so maybe avoid using it. - It suggests there's some other "app" fixture I should be using (there isn't, though). The Python style guide describes using an underscore suffix to avoid clashes with inbuilt names [1], which is sort of applicable if we need to import the "app" module [2]. However, we can also avoid clashes by choosing a different name, without the strange underscore. [1]:3b1d521c10[2]:78824f54fd/tests/app/main/views/test_forgot_password.py (L5)
This commit is contained in:
@@ -15,11 +15,11 @@ def _check_code(code):
|
||||
{'sms_code': '1-23-45'},
|
||||
])
|
||||
def test_form_is_valid_returns_no_errors(
|
||||
app_,
|
||||
notify_admin,
|
||||
mock_check_verify_code,
|
||||
post_data,
|
||||
):
|
||||
with app_.test_request_context(method='POST', data=post_data):
|
||||
with notify_admin.test_request_context(method='POST', data=post_data):
|
||||
form = TwoFactorForm(_check_code)
|
||||
assert form.validate() is True
|
||||
assert form.errors == {}
|
||||
@@ -49,32 +49,32 @@ def test_form_is_valid_returns_no_errors(
|
||||
),
|
||||
))
|
||||
def test_check_verify_code_returns_errors(
|
||||
app_,
|
||||
notify_admin,
|
||||
post_data,
|
||||
expected_error,
|
||||
mock_check_verify_code,
|
||||
):
|
||||
with app_.test_request_context(method='POST', data=post_data):
|
||||
with notify_admin.test_request_context(method='POST', data=post_data):
|
||||
form = TwoFactorForm(_check_code)
|
||||
assert form.validate() is False
|
||||
assert form.errors == {'sms_code': [expected_error]}
|
||||
|
||||
|
||||
def test_check_verify_code_returns_error_when_code_has_expired(
|
||||
app_,
|
||||
notify_admin,
|
||||
mock_check_verify_code_code_expired,
|
||||
):
|
||||
with app_.test_request_context(method='POST', data={'sms_code': '99999'}):
|
||||
with notify_admin.test_request_context(method='POST', data={'sms_code': '99999'}):
|
||||
form = TwoFactorForm(_check_code)
|
||||
assert form.validate() is False
|
||||
assert form.errors == {'sms_code': ['Code has expired']}
|
||||
|
||||
|
||||
def test_check_verify_code_returns_error_when_code_was_not_found(
|
||||
app_,
|
||||
notify_admin,
|
||||
mock_check_verify_code_code_not_found,
|
||||
):
|
||||
with app_.test_request_context(method='POST', data={'sms_code': '99999'}):
|
||||
with notify_admin.test_request_context(method='POST', data={'sms_code': '99999'}):
|
||||
form = TwoFactorForm(_check_code)
|
||||
assert form.validate() is False
|
||||
assert form.errors == {'sms_code': ['Code not found']}
|
||||
|
||||
Reference in New Issue
Block a user