mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
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 ¯\_(ツ)_/¯
23 lines
890 B
Python
23 lines
890 B
Python
from tests import create_test_user
|
|
from flask import url_for
|
|
import pytest
|
|
|
|
|
|
def test_should_show_choose_services_page(app_,
|
|
mock_login,
|
|
mock_get_user,
|
|
api_user_active,
|
|
mock_get_services):
|
|
with app_.test_request_context():
|
|
with app_.test_client() as client:
|
|
client.login(api_user_active)
|
|
response = client.get(url_for('main.choose_service'))
|
|
|
|
assert response.status_code == 200
|
|
resp_data = response.get_data(as_text=True)
|
|
assert 'Choose service' in resp_data
|
|
services = mock_get_services.side_effect()
|
|
assert mock_get_services.called
|
|
assert services['data'][0]['name'] in resp_data
|
|
assert services['data'][1]['name'] in resp_data
|