Exemple #1
0
def base_client():
    app = create_app(Path.cwd(), config_dict['Debug'], test=True)
    app_context = app.app_context()
    app_context.push()
    db.session.close()
    db.drop_all()
    yield app.test_client()
Exemple #2
0
def base_client() -> Iterator[FlaskClient]:
    app = create_app(Path.cwd(), config_dict["Debug"])
    app_context = app.app_context()
    app_context.push()
    db.session.close()
    db.drop_all()
    yield app.test_client()
Exemple #3
0
def selenium_client():
    app = create_app(Path.cwd(), config_dict['Debug'], test=True)
    app_context = app.app_context()
    app_context.push()
    db.session.close()
    db.drop_all()
    options = Options()
    options.add_argument('--headless')
    # options.add_argument('--disable-gpu')
    # Flask can run in a separate thread, but the reloader expects to run in
    # the main thread: it must be disabled
    client = None
    try:
        client = webdriver.Chrome('./tests/chromedriver',
                                  chrome_options=options)
    except Exception:
        pass
    # if the client cannot start, we don't want to start a Thread as the
    # test execution would be stuck
    if client:
        t = Thread(target=app.run,
                   kwargs={
                       'host': '0.0.0.0',
                       'port': 5000,
                       'use_reloader': False
                   })
        t.daemon = True
        t.start()
        # give the server some time to start
        sleep(1)
        yield client
        client.get('http://0.0.0.0:5000/shutdown')
        client.quit()
    app_context.pop()
Exemple #4
0
def base_client():
    app = create_app(path, test=True)
    app_context = app.app_context()
    app_context.push()
    db.session.close()
    db.drop_all()
    yield app.test_client()
Exemple #5
0
def base_client() -> Iterator[FlaskClient]:
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        app = create_app(Path.cwd(), "Test")
        app_context = app.app_context()
        app_context.push()
        Session.close()
        yield app.test_client()
Exemple #6
0
def user_client():
    app = create_app(Path.cwd(), config_dict['Debug'])
    app_context = app.app_context()
    app_context.push()
    db.session.close()
    db.drop_all()
    client = app.test_client()
    login = {'name': 'admin', 'password': '******'}
    with app.app_context():
        client.post('/admin/login', data=login)
        yield client
Exemple #7
0
def user_client():
    app = create_app(Path.cwd(), config_dict['Debug'], test=True)
    app_context = app.app_context()
    app_context.push()
    db.session.close()
    db.drop_all()
    client = app.test_client()
    create = {'name': 'test', 'password': '', 'create_account': ''}
    login = {'name': 'test', 'password': '', 'login': ''}
    with app.app_context():
        client.post('/admin/process_user', data=create)
        client.post('/admin/login', data=login)
        yield client
Exemple #8
0
def user_client() -> Iterator[FlaskClient]:
    app = create_app(Path.cwd(), config_dict["Debug"])
    app_context = app.app_context()
    app_context.push()
    db.session.close()
    db.drop_all()
    client = app.test_client()
    login = {
        "name": "admin",
        "password": "******",
        "authentication_method": "Local User",
    }
    with app.app_context():
        client.post("/admin/login", data=login)
        yield client
Exemple #9
0
def user_client() -> Iterator[FlaskClient]:
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        app = create_app(Path.cwd(), "Test")
        app_context = app.app_context()
        app_context.push()
        Session.close()
        client = app.test_client()
        with app.app_context():
            client.post(
                "/login",
                data={
                    "name": "admin",
                    "password": "******",
                    "authentication_method": "Local User",
                },
            )
            yield client
Exemple #10
0
from eNMS import create_app, db
from flask_migrate import Migrate
from os.path import abspath, dirname


app = create_app(abspath(dirname(__file__)))
Migrate(app, db)
Exemple #11
0
from os import environ
from pathlib import Path
from sys import exit

from config import config_dict
from eNMS import create_app

get_config_mode = environ.get('ENMS_CONFIG_MODE', 'Debug')

try:
    config_mode = config_dict[get_config_mode.capitalize()]
except KeyError:
    exit('Error: Invalid ENMS_CONFIG_MODE environment variable entry.')

app = create_app(Path.cwd(), config_mode)
Exemple #12
0
from os import environ
from pathlib import Path

from eNMS import create_app

app = create_app(Path.cwd(), environ.get("ENMS_CONFIG_MODE", "Debug"))