mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
Add mocked get_services to test_client.login
Because the redirect after logging in checks the number of services a user has, this now needs to be mocked. Right now this means adding `mock_get_login` to any tests that need a login. This must be one of the first mocks, so that it can be overridden by any use of `mock_get_services`, for tests that specifically want to rely on a quantity of mocked services, or their contents. This is a bit fragile, but there’s already a TODO in the code to make it better so ¯\_(ツ)_/¯
This commit is contained in:
@@ -398,11 +398,23 @@ def mock_get_no_api_keys(mocker):
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_login(mocker, mock_get_user, mock_update_user):
|
||||
|
||||
def _verify_code(user_id, code, code_type):
|
||||
return True, ''
|
||||
return mocker.patch(
|
||||
'app.user_api_client.check_verify_code',
|
||||
side_effect=_verify_code)
|
||||
|
||||
def _no_services(user_id=None):
|
||||
return {'data': []}
|
||||
|
||||
return (
|
||||
mocker.patch(
|
||||
'app.user_api_client.check_verify_code',
|
||||
side_effect=_verify_code
|
||||
),
|
||||
mocker.patch(
|
||||
'app.notifications_api_client.get_services',
|
||||
side_effect=_no_services
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
|
||||
Reference in New Issue
Block a user