def app():
    """An application for the tests."""
    app = create_app('hello_test.cfg')

    with app.app_context():
        from hello.views import hello_app
        app.register_blueprint(hello_app)
        yield app

    os.unlink(app.config['DB_PATH'])
Beispiel #2
0
import os
import click
from flask_migrate import Migrate
from hello import create_app, db
from hello.models import User, Role

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
print(app.config['SQLALCHEMY_DATABASE_URI'])
print(app.config['SQLALCHEMY_TRACK_MODIFICATIONS'])
print(app)
migrate = Migrate(app, db)


@app.shell_context_processor
def make_shell_context():
    return dict(db=db, User=User, Role=Role)


@app.cli.command()
@click.argument('test_names', nargs=-1)
def test(test_names):
    """Run the unit tests."""
    import unittest
    if test_names:
        tests = unittest.TestLoader().loadTestsFromNames(test_names)
    else:
        tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)
import pytest
from . import load_up, load_down

from hello import create_app

app, storage = create_app(storage_type="models.storage")
app.app_context().push()
storage.init_db()


@pytest.fixture
def up():
    return load_up()


@pytest.fixture
def down():
    return load_down()


def test_format(up):
    assert repr(storage) == "<DBStore with 0 events>"


def test_create_up(up):
    db_event = storage.create(up)
    assert db_event.alert_type == 2
    assert db_event.alert_name == 'Up'
    assert db_event.alert_duration == 99
    assert db_event.monitor_name == 'unittest'
    assert len(storage) == 1
Beispiel #4
0
def init_db(name=None, **kwargs):
    app, storage = create_app(storage_type="models.storage")
    app.app_context().push()
    storage.init_db()
Beispiel #5
0
from hello import create_app
import config

app = create_app('config')
app.run(host='0.0.0.0', debug=True)
Beispiel #6
0
"""App entry point."""
from hello import create_app

app = create_app()

if __name__ == "__main__":
    app.run(host='localhost', port=5000)

Beispiel #7
0
from hello import create_app

app = create_app('dev')

if __name__ == '__main__':
    app.run()
Beispiel #8
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
def app():
    app = create_app()
    yield app