109526520: Implememt verify post method.

This commit is contained in:
Rebecca Law
2015-12-04 17:10:06 +00:00
parent 69da9f8f32
commit 6d47c01117
2 changed files with 37 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
from app.main.encryption import hashpw
def test_should_return_verify_template(notifications_admin, notifications_admin_db):
@@ -5,3 +6,27 @@ def test_should_return_verify_template(notifications_admin, notifications_admin_
assert response.status_code == 200
assert 'Activate your account' in response.get_data(as_text=True)
def test_should_redirect_to_add_service_when_code_are_correct(notifications_admin, notifications_admin_db):
with notifications_admin.test_client() as client:
with client.session_transaction() as session:
session['sms_code'] = hashpw('12345')
session['email_code'] = hashpw('23456')
response = client.post('/verify',
data={'sms_code': '12345',
'email_code': '23456'})
assert response.status_code == 302
assert response.location == 'http://localhost/add-service'
def test_should_return_400_when_sms_code_is_wrong(notifications_admin, notifications_admin_db):
with notifications_admin.test_client() as client:
with client.session_transaction() as session:
session['sms_code'] = hashpw('12345')
session['email_code'] = hashpw('23456')
response = client.post('/verify',
data={'sms_code': '98765',
'email_code': '23456'})
assert response.status_code == 400
assert 'sms_code' in response.get_data(as_text=True)