Merge branch 'master' into error-handling

Conflicts:
	app/main/views/invites.py
This commit is contained in:
Rebecca Law
2016-03-10 15:03:21 +00:00
16 changed files with 219 additions and 80 deletions

View File

@@ -1,4 +1,5 @@
from flask import url_for
from bs4 import BeautifulSoup
def test_render_register_returns_template_with_form(app_):
@@ -106,3 +107,24 @@ def test_should_return_400_if_password_is_blacklisted(app_,
response.status_code == 200
assert 'That password is blacklisted, too common' in response.get_data(as_text=True)
def test_register_with_existing_email_returns_error(app_,
api_user_active,
mock_get_user_by_email):
user_data = {
'name': 'Already Hasaccount',
'email_address': api_user_active.email_address,
'mobile_number': '+4407700900460',
'password': 'validPassword!'
}
with app_.test_request_context():
response = app_.test_client().post(url_for('main.register'),
data=user_data)
assert response.status_code == 400
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
element = page.find('h1')
assert element.text == 'Create an account'
flash_banner = page.find('div', class_='banner-dangerous').string.strip()
assert flash_banner == 'There was an error registering your account'