예제 #1
0
def test_client():
    """
    This code are originally covered from this blog post: https://www.patricksoftwareblog.com/testing-a-flask-application-using-pytest/

    GitLab Repo: https://gitlab.com/patkennedy79/flask_user_management_example/blob/master/tests/conftest.py

    :return:
    """

    flask_app = server.create_app('flask_test.cfg')

    # Flask provides a way to test your application by exposing the Werkzeug test Client
    # and handling the context locals for you.
    testing_client = flask_app.test_client()

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

    yield testing_client  # this is where the testing happens!

    ctx.pop()
예제 #2
0
from src.server import create_app

APP = create_app()

if __name__ == '__main__':
    APP.run(host="0.0.0.0")
예제 #3
0
# entry point for uWSGI
from src.server import create_app

app = create_app()
예제 #4
0
def app():
    return testing.TestClient(server.create_app())
예제 #5
0
def app(mocker):
    app = server.create_app()
    return app
예제 #6
0
import os
from flask_script import Manager, Shell, Server
from src.server import create_app
from termcolor import colored


app = create_app(os.getenv('APP_STAGE') or 'dev')
manager = Manager(app)


def make_shell_context():
    return dict(app=app)


@manager.command
def run_tests():
    """Run the unit tests."""
    import unittest

    path_to_tests = os.path.join(
        os.getcwd(), "tests"
    )
    tests = unittest.TestLoader().discover(path_to_tests)
    unittest.TextTestRunner(verbosity=2).run(tests)


@manager.command
def clear_db():
    from src.api.models import Itinerarie
    Itinerarie.objects.delete()
예제 #7
0
def test_client():
    """
    Generate test client instance for Flask server.
    """
    return create_app().test_client()
예제 #8
0
from src.server import create_app

if __name__ == '__main__':
    create_app().run()
예제 #9
0
try:
    from src.server import create_app
except:
    from server import create_app

application = create_app()
application.debug = True
예제 #10
0
def client():
    app = create_app('test')
    app.testing = True
    return app.test_client()
예제 #11
0
def test_client():
    server = create_app()
    testing_client = server.test_client()

    yield testing_client