<commit_before># -*- coding: utf-8 -*-
import pytest

from skylines.model import db, User

attrs = dict(
    email_address=u"<EMAIL>",
    first_name=u"Test",
    last_name=u"User",
    password="<PASSWORD>"
)


@pytest.fixture(scope='function')
def test_user(db_session):
    obj = User(**attrs)
    db_session.add(obj)
    db_session.commit()
    return obj


def test_obj_creation_email(test_user):
    """The obj constructor must set the email right"""
    assert test_user.email_address == u"<EMAIL>"


def test_no_permissions_by_default(test_user):
    """User objects should have no permission by default."""
    assert test_user.admin == False


def test_getting_by_email(test_user):
    """Users should be fetcheable by their email addresses"""
    him = User.by_email_address(u"<EMAIL>")
    assert him == test_user


def test_query_obj(test_user):
    """Model objects can be queried"""
    obj = db.session.query(User).one()

    assert obj == test_user
    assert obj.email_address == attrs.get('email_address')
    assert obj.first_name == attrs.get('first_name')
    assert obj.last_name == attrs.get('last_name')<commit_msg>tests/model/test_auth: Use global 'test_user' fixture<commit_after># -*- coding: utf-8 -*-

from skylines.model import db, User


def test_no_permissions_by_default(test_user):
    """User objects should have no permission by default."""
    assert test_user.admin == False


def test_getting_by_email(test_user):
    """Users should be fetcheable by their email addresses"""
    him = User.by_email_address(test_user.email_address)
    assert him == test_user


def test_query_obj(test_user):
    """Model objects can be queried"""
    obj = db.session.query(User).one()

    assert obj == test_user
    assert obj.email_address == test_user.email_address
    assert obj.first_name == test_user.first_name
    assert obj.last_name == test_user.last_name
{'fraction_non_alphanumeric': 0.11985216473072861, 'fraction_numerical': 0.0010559662090813093, 'mean_word_length': 4.220385674931129, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5737444', 'n_tokens_mistral': 616, 'n_tokens_neox': 607, 'n_words': 147}