mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Reintroduce some tests. A bit of cleanup of mocks.
User object fields made a bit clearer and simple test to verify user added.
This commit is contained in:
@@ -11,12 +11,11 @@ def test_render_register_returns_template_with_form(app_, db_, db_session):
|
||||
def test_logged_in_user_redirects_to_choose_service(app_,
|
||||
db_,
|
||||
db_session,
|
||||
mock_api_user,
|
||||
mock_user_loader,
|
||||
mock_user_dao_get_by_email):
|
||||
mock_active_user,
|
||||
mock_get_by_email):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(mock_api_user)
|
||||
client.login(mock_active_user)
|
||||
response = client.get(url_for('main.register'))
|
||||
assert response.status_code == 302
|
||||
|
||||
@@ -30,10 +29,10 @@ def test_process_register_creates_new_user(app_,
|
||||
mock_send_sms,
|
||||
mock_send_email,
|
||||
mock_register_user,
|
||||
mock_user_by_email_not_found):
|
||||
mock_get_by_email):
|
||||
user_data = {
|
||||
'name': 'Some One Valid',
|
||||
'email_address': 'someone@example.gov.uk',
|
||||
'email_address': 'notfound@example.gov.uk',
|
||||
'mobile_number': '+4407700900460',
|
||||
'password': 'validPassword!'
|
||||
}
|
||||
@@ -43,6 +42,7 @@ def test_process_register_creates_new_user(app_,
|
||||
data=user_data)
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.verify', _external=True)
|
||||
assert mock_register_user.called
|
||||
|
||||
|
||||
def test_process_register_returns_400_when_mobile_number_is_invalid(app_,
|
||||
@@ -50,7 +50,7 @@ def test_process_register_returns_400_when_mobile_number_is_invalid(app_,
|
||||
db_session,
|
||||
mock_send_sms,
|
||||
mock_send_email,
|
||||
mock_user_by_email_not_found):
|
||||
mock_get_by_email):
|
||||
response = app_.test_client().post('/register',
|
||||
data={'name': 'Bad Mobile',
|
||||
'email_address': 'bad_mobile@example.gov.uk',
|
||||
@@ -66,7 +66,7 @@ def test_should_return_400_when_email_is_not_gov_uk(app_,
|
||||
db_session,
|
||||
mock_send_sms,
|
||||
mock_send_email,
|
||||
mock_user_by_email_not_found):
|
||||
mock_get_by_email):
|
||||
response = app_.test_client().post('/register',
|
||||
data={'name': 'Bad Mobile',
|
||||
'email_address': 'bad_mobile@example.not.right',
|
||||
@@ -83,11 +83,10 @@ def test_should_add_verify_codes_on_session(app_,
|
||||
mock_send_sms,
|
||||
mock_send_email,
|
||||
mock_register_user,
|
||||
mock_user_loader,
|
||||
mock_user_by_email_not_found):
|
||||
mock_get_by_email):
|
||||
user_data = {
|
||||
'name': 'Test Codes',
|
||||
'email_address': 'test@example.gov.uk',
|
||||
'email_address': 'notfound@example.gov.uk',
|
||||
'mobile_number': '+4407700900460',
|
||||
'password': 'validPassword!'
|
||||
}
|
||||
@@ -99,7 +98,10 @@ def test_should_add_verify_codes_on_session(app_,
|
||||
assert 'notify_admin_session' in response.headers.get('Set-Cookie')
|
||||
|
||||
|
||||
def test_should_return_400_if_password_is_blacklisted(app_, db_, db_session, mock_user_by_email_not_found):
|
||||
def test_should_return_400_if_password_is_blacklisted(app_,
|
||||
db_,
|
||||
db_session,
|
||||
mock_get_by_email):
|
||||
response = app_.test_client().post('/register',
|
||||
data={'name': 'Bad Mobile',
|
||||
'email_address': 'bad_mobile@example.not.right',
|
||||
|
||||
Reference in New Issue
Block a user