mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
Tests added for dao.
This commit is contained in:
@@ -5,8 +5,8 @@ from app.main.forms import TwoFactorForm
|
||||
from tests.app.main import create_test_user
|
||||
|
||||
|
||||
def test_form_is_valid_returns_no_errors(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context(method='POST',
|
||||
def test_form_is_valid_returns_no_errors(app_, db_, db_session):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': '12345'}) as req:
|
||||
user = set_up_test_data()
|
||||
codes = verify_codes_dao.get_codes(user.id)
|
||||
@@ -15,8 +15,8 @@ def test_form_is_valid_returns_no_errors(notifications_admin, notifications_admi
|
||||
assert len(form.errors) == 0
|
||||
|
||||
|
||||
def test_returns_errors_when_code_is_too_short(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context(method='POST',
|
||||
def test_returns_errors_when_code_is_too_short(app_, db_, db_session):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': '145'}) as req:
|
||||
user = set_up_test_data()
|
||||
codes = verify_codes_dao.get_codes(user.id)
|
||||
@@ -26,8 +26,8 @@ def test_returns_errors_when_code_is_too_short(notifications_admin, notification
|
||||
assert set(form.errors) == set({'sms_code': ['Code must be 5 digits', 'Code does not match']})
|
||||
|
||||
|
||||
def test_returns_errors_when_code_is_missing(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context(method='POST',
|
||||
def test_returns_errors_when_code_is_missing(app_, db_, db_session):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={}) as req:
|
||||
user = set_up_test_data()
|
||||
codes = verify_codes_dao.get_codes(user.id)
|
||||
@@ -37,8 +37,8 @@ def test_returns_errors_when_code_is_missing(notifications_admin, notifications_
|
||||
assert set(form.errors) == set({'sms_code': ['Code must not be empty']})
|
||||
|
||||
|
||||
def test_returns_errors_when_code_contains_letters(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context(method='POST',
|
||||
def test_returns_errors_when_code_contains_letters(app_, db_, db_session):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': 'asdfg'}) as req:
|
||||
user = set_up_test_data()
|
||||
codes = verify_codes_dao.get_codes(user.id)
|
||||
@@ -48,8 +48,8 @@ def test_returns_errors_when_code_contains_letters(notifications_admin, notifica
|
||||
assert set(form.errors) == set({'sms_code': ['Code must be 5 digits', 'Code does not match']})
|
||||
|
||||
|
||||
def test_should_return_errors_when_code_is_expired(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
with notifications_admin.test_request_context(method='POST',
|
||||
def test_should_return_errors_when_code_is_expired(app_, db_, db_session):
|
||||
with app_.test_request_context(method='POST',
|
||||
data={'sms_code': '23456'}) as req:
|
||||
user = create_test_user('active')
|
||||
verify_codes_dao.add_code_with_expiry(user_id=user.id,
|
||||
|
||||
Reference in New Issue
Block a user