Test for VerifyForm and TwoFactorForm

This commit is contained in:
Rebecca Law
2015-12-14 14:09:29 +00:00
parent 295dbeb7d1
commit caabda92e0
4 changed files with 9 additions and 33 deletions

View File

@@ -35,27 +35,3 @@ def test_should_return_400_with_sms_code_error_when_sms_code_is_wrong(notificati
data={'sms_code': '23456'})
assert response.status_code == 400
assert {'sms_code': ['Code does not match']} == json.loads(response.get_data(as_text=True))
def test_should_return_400_when_sms_code_is_empty(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_client() as client:
with client.session_transaction() as session:
user = create_test_user()
session['user_id'] = user.id
verify_codes_dao.add_code(user_id=user.id, code='12345', code_type='sms')
response = client.post('/two-factor')
assert response.status_code == 400
assert {'sms_code': ['Please enter your code']} == json.loads(response.get_data(as_text=True))
def test_should_return_400_when_sms_code_is_too_short(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_client() as client:
with client.session_transaction() as session:
user = create_test_user()
session['user_id'] = user.id
verify_codes_dao.add_code(user_id=user.id, code='23467', code_type='sms')
response = client.post('/two-factor', data={'sms_code': '2346'})
assert response.status_code == 400
data = json.loads(response.get_data(as_text=True))
assert len(data.keys()) == 1
assert set(data) == set({'sms_code': ['Code must be 5 digits', 'Code does not match']})