Tests added for dao.

This commit is contained in:
Nicholas Staples
2016-01-15 15:15:35 +00:00
parent d42ee85f93
commit 3b1d521c10
39 changed files with 769 additions and 652 deletions

View File

@@ -4,17 +4,17 @@ from pytest import fail
from app.notify_client.sender import generate_token, check_token
def test_should_return_email_from_signed_token(notifications_admin,
notifications_admin_db,
notify_db_session):
def test_should_return_email_from_signed_token(app_,
db_,
db_session):
email = 'email@something.com'
token = generate_token(email)
assert email == check_token(token)
def test_should_throw_exception_when_token_is_tampered_with(notifications_admin,
notifications_admin_db,
notify_db_session):
def test_should_throw_exception_when_token_is_tampered_with(app_,
db_,
db_session):
email = 'email@something.com'
token = generate_token(email)
try:
@@ -24,12 +24,12 @@ def test_should_throw_exception_when_token_is_tampered_with(notifications_admin,
pass
def test_return_none_when_token_is_expired(notifications_admin,
notifications_admin_db,
notify_db_session):
with notifications_admin.test_request_context():
notifications_admin.config['TOKEN_MAX_AGE_SECONDS'] = -1000
def test_return_none_when_token_is_expired(app_,
db_,
db_session):
with app_.test_request_context():
app_.config['TOKEN_MAX_AGE_SECONDS'] = -1000
email = 'email@something.com'
token = generate_token(email)
assert check_token(token) is None
notifications_admin.config['TOKEN_MAX_AGE_SECONDS'] = 120000
app_.config['TOKEN_MAX_AGE_SECONDS'] = 120000