# Path: models/authentication_tokens.py
# class AuthenticationTokens(bases.BaseModel):
#     def __init__(self, *args, **kwargs):
#     def _expiration():
#     def _gen_token():
#     def get_by_token(cls, token):
# 
# Path: models/logins.py
# class Logins(bases.BaseModel):
#     def get_by_email(cls, email):
#     def is_valid_password(self, password):
#     def password(self):
#     def password(self, value):
#     def validate_email(self, key, address):  # pylint: disable=unused-argument,no-self-use
# 
# Path: models/profiles.py
# class Profiles(bases.BaseModel):
#     def get_by_email(cls, email):
#     def validate_email(self, key, address):  # pylint: disable=unused-argument,no-self-use


    from builtins import *  # pylint: disable=unused-wildcard-import,redefined-builtin,wildcard-import
from sqlalchemy.exc import IntegrityError
from models import authentication_tokens as autht
from models import logins, profiles
    import sys
import datetime
import re
import warnings
import pytest

def test_expiration():
    """ Expiration should be 3 days from now. """
    exp_dt = autht.AuthenticationTokens._expiration().replace(microsecond=0)   # pylint: disable=protected-access
    assert exp_dt == datetime.datetime.utcnow().replace(microsecond=0) + \
        datetime.timedelta(minutes=30)

def test_new_token_init():
    """ By default new tokens should default to a token and an expiration. """
    token = autht.AuthenticationTokens()
    assert token.token
    assert token.expiration_dt

def test_required_login_missing(dbsession):
    """
    Tokens without a login relationship should error.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """
    token = autht.AuthenticationTokens()
    token.save()
    assert token.login_id is None

    with pytest.raises(IntegrityError):
        dbsession.commit()

def test_required_login(dbsession):
    """
    Tokens must have a login relation (which must have a profile relation).
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """

# Path: models/authentication_tokens.py
# class AuthenticationTokens(bases.BaseModel):
#     def __init__(self, *args, **kwargs):
#     def _expiration():
#     def _gen_token():
#     def get_by_token(cls, token):
# 
# Path: models/logins.py
# class Logins(bases.BaseModel):
#     def get_by_email(cls, email):
#     def is_valid_password(self, password):
#     def password(self):
#     def password(self, value):
#     def validate_email(self, key, address):  # pylint: disable=unused-argument,no-self-use
# 
# Path: models/profiles.py
# class Profiles(bases.BaseModel):
#     def get_by_email(cls, email):
#     def validate_email(self, key, address):  # pylint: disable=unused-argument,no-self-use


# Path: tests/models/test_authentication_tokens.py
    from builtins import *  # pylint: disable=unused-wildcard-import,redefined-builtin,wildcard-import
from sqlalchemy.exc import IntegrityError
from models import authentication_tokens as autht
from models import logins, profiles
    import sys
import datetime
import re
import warnings
import pytest


def test_expiration():
    """ Expiration should be 3 days from now. """
    exp_dt = autht.AuthenticationTokens._expiration().replace(microsecond=0)   # pylint: disable=protected-access
    assert exp_dt == datetime.datetime.utcnow().replace(microsecond=0) + \
        datetime.timedelta(minutes=30)

def test_new_token_init():
    """ By default new tokens should default to a token and an expiration. """
    token = autht.AuthenticationTokens()
    assert token.token
    assert token.expiration_dt

def test_required_login_missing(dbsession):
    """
    Tokens without a login relationship should error.
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """
    token = autht.AuthenticationTokens()
    token.save()
    assert token.login_id is None

    with pytest.raises(IntegrityError):
        dbsession.commit()

def test_required_login(dbsession):
    """
    Tokens must have a login relation (which must have a profile relation).
    :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session
    """

    profile = profiles.Profiles(full_name='3ea4a6ec 7bb15fa70936', email='4523@45dc.a65b')