예제 #1
0
def api_client(sample_room1, sample_room2, sample_vlan):
    from .context import app
    with app.app.test_client() as c:
        db.init_db(db_settings, testing=True)
        prep_db(db.get_db().get_session(),
                sample_room1, sample_room2, sample_vlan)
        yield c
예제 #2
0
def api_client(member1,
               member2,
               wired_device,
               wireless_device):
    from .context import app
    with app.app.test_client() as c:
        db.init_db(db_settings, testing=True)
        prep_db(db.get_db().get_session(),
                member1,
                member2,
                wired_device,
                wireless_device)
        yield c
예제 #3
0
#!/usr/bin/env python3
import connexion
import logging
from flask_cors import CORS
from adh.model.database import Database
from CONFIGURATION import PROD_DATABASE as DATABASE
from connexion.resolver import RestyResolver
from CONFIGURATION import API_CONF

Database.init_db(DATABASE)

logging.basicConfig(level=logging.INFO)
app = connexion.FlaskApp(__name__)
app.app.config.update(API_CONF)
app.add_api('swagger.yaml',
            resolver=RestyResolver('adh.controller'),
            strict_validation=True)
CORS(app.app)
# set the WSGI application callable to allow using uWSGI:
# uwsgi --http :8080 -w app
application = app.app


@application.teardown_appcontext
def shutdown_session(exception=None):
    if Database.get_db():
        Database.get_db().remove_session()