Пример #1
0
def test_get_db_while_testing(app):
    app = create_app({"TESTING": True})

    with app.app_context():
        db = get_db()
        assert hasattr(db, "name")
        assert isinstance(db, mongomock.database.Database)
Пример #2
0
def test_create_app_registers_blueprints():
    app = create_app()
    assert len(app.blueprints) == 5
    assert app.blueprints["links"]
    assert app.blueprints["preferences"]
    assert app.blueprints["views"]
    assert app.blueprints["notes"]
    assert app.blueprints["archive"]
Пример #3
0
def test_get_connection_while_not_testing():
    app = create_app({"TESTING": False})

    with app.app_context():
        assert not hasattr(g, "connection")
        connection = get_connection()
        assert hasattr(g, "connection")
        assert isinstance(connection, MongoClient)
Пример #4
0
def app():
    app = create_app({"TESTING": True})

    ctx = app.app_context()
    ctx.push()

    yield app

    ctx.pop()
Пример #5
0
def test_create_app_testing_config():
    assert not create_app().testing
    assert create_app({"TESTING": True}).testing
Пример #6
0
def test_create_app_override_config():
    app = create_app({"secret_key": "RANXOM"})
    assert app.config["secret_key"] == "RANXOM"