move invite error handler to top level

ensure we catch org errors as well as regular errors
This commit is contained in:
Leo Hemsted
2020-03-06 11:53:55 +00:00
parent be48f3bac5
commit 2d8d2d712a
5 changed files with 20 additions and 14 deletions

View File

@@ -308,12 +308,18 @@ def test_cancelled_invited_user_accepts_invited_redirect_to_cancelled_invitation
assert page.h1.string.strip() == 'The invitation you were sent has been cancelled'
@pytest.mark.parametrize('admin_endpoint, api_endpoint', [
('main.accept_invite', 'app.invite_api_client.check_token'),
('main.accept_org_invite', 'app.org_invite_api_client.check_token'),
])
def test_new_user_accept_invite_with_malformed_token(
admin_endpoint,
api_endpoint,
client,
service_one,
mocker,
):
mocker.patch('app.invite_api_client.check_token', side_effect=HTTPError(
mocker.patch(api_endpoint, side_effect=HTTPError(
response=Mock(
status_code=400,
json={
@@ -328,7 +334,7 @@ def test_new_user_accept_invite_with_malformed_token(
message={'invitation': 'Somethings wrong with this link. Make sure youve copied the whole thing.'}
))
response = client.get(url_for('main.accept_invite', token='thisisnotarealtoken'), follow_redirects=True)
response = client.get(url_for(admin_endpoint, token='thisisnotarealtoken'), follow_redirects=True)
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')