mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -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:
@@ -13,21 +13,21 @@ from app.event_handlers import (
|
||||
from app.models.user import User
|
||||
|
||||
|
||||
def test_on_user_logged_in_calls_events_api(app_, api_user_active, mock_events):
|
||||
def test_on_user_logged_in_calls_events_api(notify_admin, api_user_active, mock_events):
|
||||
|
||||
with app_.test_request_context():
|
||||
on_user_logged_in(app_, User(api_user_active))
|
||||
with notify_admin.test_request_context():
|
||||
on_user_logged_in(notify_admin, User(api_user_active))
|
||||
mock_events.assert_called_with('sucessful_login',
|
||||
{'browser_fingerprint':
|
||||
{'browser': ANY, 'version': ANY, 'platform': ANY, 'user_agent_string': ''},
|
||||
'ip_address': ANY, 'user_id': str(api_user_active['id'])})
|
||||
|
||||
|
||||
def test_create_email_change_event_calls_events_api(app_, mock_events):
|
||||
def test_create_email_change_event_calls_events_api(notify_admin, mock_events):
|
||||
user_id = str(uuid.uuid4())
|
||||
updated_by_id = str(uuid.uuid4())
|
||||
|
||||
with app_.test_request_context():
|
||||
with notify_admin.test_request_context():
|
||||
create_email_change_event(user_id, updated_by_id, 'original@example.com', 'new@example.com')
|
||||
|
||||
mock_events.assert_called_with('update_user_email',
|
||||
@@ -40,12 +40,12 @@ def test_create_email_change_event_calls_events_api(app_, mock_events):
|
||||
'new_email_address': 'new@example.com'})
|
||||
|
||||
|
||||
def test_create_add_user_to_service_event_calls_events_api(app_, mock_events):
|
||||
def test_create_add_user_to_service_event_calls_events_api(notify_admin, mock_events):
|
||||
user_id = str(uuid.uuid4())
|
||||
invited_by_id = str(uuid.uuid4())
|
||||
service_id = str(uuid.uuid4())
|
||||
|
||||
with app_.test_request_context():
|
||||
with notify_admin.test_request_context():
|
||||
create_add_user_to_service_event(user_id, invited_by_id, service_id)
|
||||
|
||||
mock_events.assert_called_with(
|
||||
@@ -60,12 +60,12 @@ def test_create_add_user_to_service_event_calls_events_api(app_, mock_events):
|
||||
)
|
||||
|
||||
|
||||
def test_create_remove_user_from_service_event_calls_events_api(app_, mock_events):
|
||||
def test_create_remove_user_from_service_event_calls_events_api(notify_admin, mock_events):
|
||||
user_id = str(uuid.uuid4())
|
||||
removed_by_id = str(uuid.uuid4())
|
||||
service_id = str(uuid.uuid4())
|
||||
|
||||
with app_.test_request_context():
|
||||
with notify_admin.test_request_context():
|
||||
create_remove_user_from_service_event(user_id, removed_by_id, service_id)
|
||||
|
||||
mock_events.assert_called_with(
|
||||
@@ -80,11 +80,11 @@ def test_create_remove_user_from_service_event_calls_events_api(app_, mock_event
|
||||
)
|
||||
|
||||
|
||||
def test_create_mobile_number_change_event_calls_events_api(app_, mock_events):
|
||||
def test_create_mobile_number_change_event_calls_events_api(notify_admin, mock_events):
|
||||
user_id = str(uuid.uuid4())
|
||||
updated_by_id = str(uuid.uuid4())
|
||||
|
||||
with app_.test_request_context():
|
||||
with notify_admin.test_request_context():
|
||||
create_mobile_number_change_event(user_id, updated_by_id, '07700900000', '07700900999')
|
||||
|
||||
mock_events.assert_called_with('update_user_mobile_number',
|
||||
@@ -97,11 +97,11 @@ def test_create_mobile_number_change_event_calls_events_api(app_, mock_events):
|
||||
'new_mobile_number': '07700900999'})
|
||||
|
||||
|
||||
def test_create_archive_user_event_calls_events_api(app_, mock_events):
|
||||
def test_create_archive_user_event_calls_events_api(notify_admin, mock_events):
|
||||
user_id = str(uuid.uuid4())
|
||||
archived_by_id = str(uuid.uuid4())
|
||||
|
||||
with app_.test_request_context():
|
||||
with notify_admin.test_request_context():
|
||||
create_archive_user_event(user_id, archived_by_id)
|
||||
|
||||
mock_events.assert_called_with('archive_user',
|
||||
@@ -112,11 +112,11 @@ def test_create_archive_user_event_calls_events_api(app_, mock_events):
|
||||
'archived_by_id': archived_by_id})
|
||||
|
||||
|
||||
def test_create_broadcast_account_type_change_event(app_, mock_events):
|
||||
def test_create_broadcast_account_type_change_event(notify_admin, mock_events):
|
||||
service_id = str(uuid.uuid4())
|
||||
changed_by_id = str(uuid.uuid4())
|
||||
|
||||
with app_.test_request_context():
|
||||
with notify_admin.test_request_context():
|
||||
create_broadcast_account_type_change_event(
|
||||
service_id,
|
||||
changed_by_id,
|
||||
|
||||
Reference in New Issue
Block a user