Add pages to invite, edit, and delete users

This takes the original prototype version of this page, and, using the same
fake data (ie nothing is wired up):
- adds an invite users page
- adds an edit (and delete) user page

Both these pages allow the user to set another user’s permissions.

This commit adds images for the ticks and crosses, so we have control over their
appearance.
This commit is contained in:
Chris Hill-Scott
2016-02-19 15:02:13 +00:00
parent a86be302ce
commit 17b99c9bf2
23 changed files with 443 additions and 132 deletions

View File

@@ -0,0 +1,87 @@
import json
from flask import url_for
def test_should_show_overview_page(
app_,
api_user_active,
mock_login,
mock_get_service
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.get(url_for('main.manage_users', service_id=55555))
assert 'Manage team' in response.get_data(as_text=True)
assert 'Henry Hadlow' in response.get_data(as_text=True)
assert 'caley.smolska' in response.get_data(as_text=True)
assert response.status_code == 200
def test_should_show_page_for_one_user(
app_,
api_user_active,
mock_login,
mock_get_service
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.get(url_for('main.edit_user', service_id=55555, user_id=0))
assert 'Henry Hadlow' in response.get_data(as_text=True)
assert response.status_code == 200
def test_redirect_after_saving_user(
app_,
api_user_active,
mock_login,
mock_get_service
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.post(url_for(
'main.edit_user', service_id=55555, user_id=0
))
assert response.status_code == 302
assert response.location == url_for(
'main.manage_users', service_id=55555, _external=True
)
def test_should_show_page_for_inviting_user(
app_,
api_user_active,
mock_login,
mock_get_service
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.get(url_for('main.invite_user', service_id=55555))
assert 'Add a new team member' in response.get_data(as_text=True)
assert response.status_code == 200
def test_invite_user(
app_,
api_user_active,
mock_login,
mock_get_service
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.post(
url_for('main.invite_user', service_id=55555),
data={'email_address': 'test@example.gov.uk'},
follow_redirects=True
)
assert response.status_code == 200
assert 'Invite sent to test@example.gov.uk' in response.get_data(as_text=True)