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

"""
:Copyright: 2006-2015 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from contextlib import contextmanager
from unittest import TestCase

from byceps.application import create_app
from byceps.database import db

from testfixtures.brand import create_brand
from testfixtures.party import create_party
from testfixtures.user import create_user


class AbstractAppTestCase(TestCase):

    def setUp(self, env='test'):
        self.app = create_app(env)

        self.db = db
        db.app = self.app

        db.reflect()
        db.drop_all()
        db.create_all()

        self.create_brand_and_party()
        self.create_admin()

    def create_brand_and_party(self):
        self.brand = create_brand()
        db.session.add(self.brand)
<commit_msg>Allow overriding of database URI from the environment (e.g. when using Travis CI).<commit_after># -*- coding: utf-8 -*-

"""
:Copyright: 2006-2015 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from contextlib import contextmanager
import os
from unittest import TestCase

from byceps.application import create_app
from byceps.database import db

from testfixtures.brand import create_brand
from testfixtures.party import create_party
from testfixtures.user import create_user


class AbstractAppTestCase(TestCase):

    def setUp(self, env='test'):
        # Allow overriding of database URI from the environment.
        db_uri_override = os.environ.get('DATABASE_URI')
        if db_uri_override:
            app.config['SQLALCHEMY_DATABASE_URI'] = db_uri_override

        self.app = create_app(env)

        self.db = db
        db.app = self.app

        db.reflect()
        db.drop_all()
        db.create_all()

        self.create_brand_and_party()
        self.create_admin()

    def create_brand_and_party(self):
        self.brand = create_brand()
        db.session.add(self.brand)

{'fraction_non_alphanumeric': 0.091995841995842, 'fraction_numerical': 0.009355509355509356, 'mean_word_length': 3.148706896551724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3482367', 'n_tokens_mistral': 601, 'n_tokens_neox': 565, 'n_words': 152}