Exemple #1
0
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

        app = create_app("strabo.settings.DevConfig")

        assert app.config["DEBUG"] is True
        assert app.config["SQLALCHEMY_DATABASE_URI"] == "postgresql://localhost/strabo"
        assert app.config["CACHE_TYPE"] == "null"
Exemple #2
0
    def test_test_config(self):
        """ Tests if the test config loads correctly """

        app = create_app("strabo.settings.TestConfig")

        assert app.config["DEBUG"] is True
        assert app.config["SQLALCHEMY_ECHO"] is True
        assert app.config["CACHE_TYPE"] == "null"
Exemple #3
0
    def test_test_config(self):
        """ Tests if the test config loads correctly """

        app = create_app('strabo.settings.TestConfig')

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_ECHO'] is True
        assert app.config['CACHE_TYPE'] == 'null'
Exemple #4
0
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

        app = create_app('strabo.settings.DevConfig')

        assert app.config['DEBUG'] is True
        assert app.config[
            'SQLALCHEMY_DATABASE_URI'] == 'postgresql://localhost/strabo'
        assert app.config['CACHE_TYPE'] == 'null'
Exemple #5
0
def testapp(request):
    app = create_app('strabo.settings.TestConfig')
    client = app.test_client()

    db.app = app
    db.create_all()

    if getattr(request.module, "create_user", True):
        test_user = User('firsty', 'lasty', '*****@*****.**',
                         'supersafepassword')
        db.session.add(test_user)
        db.session.commit()

    def teardown():
        db.session.remove()
        db.drop_all()

    request.addfinalizer(teardown)

    return client
Exemple #6
0
def testapp(request):
    app = create_app('strabo.settings.TestConfig')
    client = app.test_client()

    db.app = app
    db.create_all()

    if getattr(request.module, "create_user", True):
        test_user = User('firsty', 'lasty', '*****@*****.**',
                         'supersafepassword')
        db.session.add(test_user)
        db.session.commit()

    def teardown():
        db.session.remove()
        db.drop_all()

    request.addfinalizer(teardown)

    return client
Exemple #7
0
#!/usr/bin/env python

import os

from flask_script import Manager, Shell, Server
from flask_script.commands import ShowUrls, Clean
from strabo.app import create_app
from strabo.models import db, User

# default to dev config
env = os.environ.get('STRABO_ENV', 'dev')
app = create_app('strabo.settings.%sConfig' % env.capitalize())

HERE = os.path.abspath(os.path.dirname(__file__))
TEST_PATH = os.path.join(HERE, 'tests')

manager = Manager(app)


def _make_context():
    """Return context dict for a shell session so you can access
       app, db, and the User model by default.
    """
    return {'app': app, 'db': db, 'User': User}


@manager.command
def test():
    """Run the tests."""
    import pytest
    exit_code = pytest.main([TEST_PATH, '--verbose'])