Beispiel #1
0
def app(request):
    test_config = dict(
        SQLALCHEMY_DATABASE_URI='sqlite:///:memory:',  # In-memory sqlite DB
        TESTING=True,  # Propagate exceptions (don't show 500 error page)
        WTF_CSRF_ENABLED=False,  # Disable CSRF token in Flask-Wtf
        LOGIN_DISABLED=False,  # Enable @register_required while app.testing=True
        MAIL_SUPPRESS_SEND=True,  # Suppress the sending of emails
        SERVER_NAME='localhost'  # Enable url_for() without request context
    )

    # Create app with test settings
    app = create_app(test_config)

    # Establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app
Beispiel #2
0
def app(request):
    test_config = dict(
        SQLALCHEMY_DATABASE_URI='sqlite:///:memory:',   # In-memory sqlite DB
        TESTING=True,            # Propagate exceptions (don't show 500 error page)
        WTF_CSRF_ENABLED=False,  # Disable CSRF token in Flask-Wtf
        LOGIN_DISABLED=False,    # Enable @register_required while app.testing=True
        MAIL_SUPPRESS_SEND=True, # Suppress the sending of emails
        SERVER_NAME='localhost'  # Enable url_for() without request context
    )

    # Create app with test settings
    app = create_app(test_config)

    # Establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app
Beispiel #3
0
from __future__ import print_function
import unittest

# Configure app
from flask_user.tests import test_valid_forms, test_authorization, tst_app, test_invalid_forms, tstutils

test_config = dict(
    SQLALCHEMY_DATABASE_URI='sqlite:///:memory:',   # In-memory sqlite DB
    WTF_CSRF_ENABLED=False,  # Disable CSRF token in Flask-Wtf
    LOGIN_DISABLED=False,    # Enable @register_required while app.testing=True
    MAIL_SUPPRESS_SEND=True, # Suppress the sending of emails
    SERVER_NAME='localhost'  # Enable url_for() without request context
)

# Create app
app = tst_app.create_app(test_config)
app.testing = True           # Propagate exceptions (don't show 500 error page)
db = app.user_manager.db_adapter.db

# create client
client = tstutils.TstClient(app.test_client(), db)

# Create test case
class TestFlaskUserForms(unittest.TestCase):
    """
    Automated tests for Flask-User forms
    """
    def test_authorization(self):
        with app.app_context():
            test_authorization.test_authorization(client)
Beispiel #4
0
from __future__ import print_function
import unittest

# Configure app
from flask_user.tests import test_valid_forms, test_authorization, tst_app, test_invalid_forms, tstutils

test_config = dict(
    SQLALCHEMY_DATABASE_URI='sqlite:///:memory:',  # In-memory sqlite DB
    WTF_CSRF_ENABLED=False,  # Disable CSRF token in Flask-Wtf
    LOGIN_DISABLED=False,  # Enable @register_required while app.testing=True
    MAIL_SUPPRESS_SEND=True,  # Suppress the sending of emails
    SERVER_NAME='localhost'  # Enable url_for() without request context
)

# Create app
app = tst_app.create_app(test_config)
app.testing = True  # Propagate exceptions (don't show 500 error page)
db = app.user_manager.db_adapter.db

# create client
client = tstutils.TstClient(app.test_client(), db)


# Create test case
class TestFlaskUserForms(unittest.TestCase):
    """
    Automated tests for Flask-User forms
    """
    def test_authorization(self):
        with app.app_context():
            test_authorization.test_authorization(client)